@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | } |
254 | 254 | if (!$this->config->has('app.import')) { |
255 | 255 | $this->config->set('app.import', [ |
256 | - 0 => \constant('NEBULA_APP').'/' .'share', |
|
256 | + 0 => \constant('NEBULA_APP').'/'.'share', |
|
257 | 257 | ]); |
258 | 258 | } |
259 | 259 | if (!$this->config->has('app.resource')) { |
260 | 260 | $this->config->set('app.resource', [ |
261 | - 0 => \constant('NEBULA_APP').'/' .'resource', |
|
261 | + 0 => \constant('NEBULA_APP').'/'.'resource', |
|
262 | 262 | ]); |
263 | 263 | } |
264 | 264 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | */ |
360 | 360 | public function run() |
361 | 361 | { |
362 | - $className = $this->config->get('app.application', Application::class); |
|
362 | + $className = $this->config->get('app.application', Application::class); |
|
363 | 363 | $this->application = Runnable::newClassInstance($className); |
364 | 364 | $this->application->setNebula($this); |
365 | 365 | $this->application->initialization(); |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | * @param int $expire 过期时间 |
33 | 33 | * @return bool |
34 | 34 | */ |
35 | - public function set(string $name, $value, int $expire=null):bool |
|
35 | + public function set(string $name, $value, int $expire = null):bool |
|
36 | 36 | { |
37 | 37 | if ($this->disable()) { |
38 | 38 | return false; |
39 | 39 | } |
40 | - $path=$this->getPath($name); |
|
41 | - $this->value[$name]=$value; |
|
40 | + $path = $this->getPath($name); |
|
41 | + $this->value[$name] = $value; |
|
42 | 42 | FileSystem::makes(dirname($path)); |
43 | - $value=serialize($value); |
|
43 | + $value = serialize($value); |
|
44 | 44 | if (is_null($expire)) { |
45 | - $expire=time() + $this->defaultLiveTime; |
|
45 | + $expire = time() + $this->defaultLiveTime; |
|
46 | 46 | } |
47 | - return file_put_contents($path, $expire.'|'.$value)!==false; |
|
47 | + return file_put_contents($path, $expire.'|'.$value) !== false; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -52,19 +52,19 @@ discard block |
||
52 | 52 | * @param string $name 名 |
53 | 53 | * @return mixed|null |
54 | 54 | */ |
55 | - public function get(string $name, $defalut=null) |
|
55 | + public function get(string $name, $defalut = null) |
|
56 | 56 | { |
57 | 57 | // 有值就获取值 |
58 | 58 | if (array_key_exists($name, $this->value)) { |
59 | - $value=$this->value[$name]; |
|
59 | + $value = $this->value[$name]; |
|
60 | 60 | return $value; |
61 | 61 | } |
62 | 62 | // 没值就在cache文件中查找 |
63 | - $path=$this->getPath($name); |
|
63 | + $path = $this->getPath($name); |
|
64 | 64 | if (FileSystem::exist($path)) { |
65 | - $value=FileSystem::get($path); |
|
66 | - list($time, $value)=explode('|', $value, 2); |
|
67 | - if (time()<intval($time)) { |
|
65 | + $value = FileSystem::get($path); |
|
66 | + list($time, $value) = explode('|', $value, 2); |
|
67 | + if (time() < intval($time)) { |
|
68 | 68 | // 未过期则返回 |
69 | 69 | return unserialize($value); |
70 | 70 | } else { |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function has(string $name):bool |
97 | 97 | { |
98 | - return $this->get($name)!==null; |
|
98 | + return $this->get($name) !== null; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function gc() |
105 | 105 | { |
106 | - $files=FileSystem::readFiles($this->path, true); |
|
106 | + $files = FileSystem::readFiles($this->path, true); |
|
107 | 107 | foreach ($files as $file) { |
108 | - $value=FileSystem::get($file); |
|
109 | - list($time, $value)=explode('|', $value, 2); |
|
110 | - if (time()>intval($time)) { |
|
108 | + $value = FileSystem::get($file); |
|
109 | + list($time, $value) = explode('|', $value, 2); |
|
110 | + if (time() > intval($time)) { |
|
111 | 111 | FileSystem::delete($file); |
112 | 112 | } |
113 | 113 | } |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | private function getPath(string $name) |
132 | 132 | { |
133 | 133 | if (strpos($name, '.')) { |
134 | - list($main, $sub)=explode('.', $name, 2); |
|
134 | + list($main, $sub) = explode('.', $name, 2); |
|
135 | 135 | } else { |
136 | - $main=$name; |
|
137 | - $sub=$name; |
|
136 | + $main = $name; |
|
137 | + $sub = $name; |
|
138 | 138 | } |
139 | - $fname= $this->path.'/'.$main.'/'.substr(md5($sub), 0, 4).'.cache'; |
|
139 | + $fname = $this->path.'/'.$main.'/'.substr(md5($sub), 0, 4).'.cache'; |
|
140 | 140 | return $fname; |
141 | 141 | } |
142 | 142 | } |