-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUtility.php
More file actions
62 lines (54 loc) · 1.59 KB
/
Utility.php
File metadata and controls
62 lines (54 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace EasySwoole\EasySwoole\Command;
use EasySwoole\Utility\File;
class Utility
{
public static function easySwooleLog()
{
return <<<'LOGO'
_ _ __ __ ____ _____ ____ _____
| | | | \ \ / / | _ \ | ____| | _ \ | ___|
| |_| | \ V / | |_) | | _| | |_) | | |_
| _ | | | | __/ | |___ | _ < | _|
|_| |_| |_| |_| |_____| |_| \_\ |_|
LOGO;
}
public static function displayItem($name, $value)
{
return "\e[32m" . str_pad($name, 30, ' ', STR_PAD_RIGHT) . "\e[34m" . $value . "\e[0m";
}
public static function releaseResource($source, $destination)
{
clearstatcache();
$replace = true;
if (is_file($destination)) {
$filename = basename($destination);
echo "{$filename} has already existed, do you want to replace it? [ Y / N (default) ] : ";
$answer = strtolower(trim(strtoupper(fgets(STDIN))));
if (! in_array($answer, ['y', 'yes'])) {
$replace = false;
}
}
if ($replace) {
File::copyFile($source, $destination);
}
}
public static function opCacheClear()
{
if (function_exists('apc_clear_cache')) {
apc_clear_cache();
}
if (function_exists('opcache_reset')) {
opcache_reset();
}
}
}