@@ -23,15 +23,15 @@ |
||
23 | 23 | $names = $this->valiable->getNames(); |
24 | 24 | $tmp = []; |
25 | 25 | $len = 0; |
26 | - foreach ( $names as $name ) { |
|
26 | + foreach ($names as $name) { |
|
27 | 27 | $len = strlen($name) > $len ? strlen($name) : $len; |
28 | 28 | $tmp[] = [ |
29 | 29 | 'name' => $name, |
30 | 30 | 'items' => serialize($this->valiable->get($name)), |
31 | 31 | ]; |
32 | 32 | } |
33 | - $headers = ['name','items']; |
|
34 | - $this->table($headers,$tmp); |
|
33 | + $headers = ['name', 'items']; |
|
34 | + $this->table($headers, $tmp); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 |
@@ -25,7 +25,9 @@ |
||
25 | 25 | throw new \Exception('value is null'); |
26 | 26 | } |
27 | 27 | $data = $this->cache->get($this->prefix . $name); |
28 | - if ( ! $data ) return null; |
|
28 | + if ( ! $data ) { |
|
29 | + return null; |
|
30 | + } |
|
29 | 31 | |
30 | 32 | $data = $this->decode($data); |
31 | 33 | if ( isset($data[$key]) === false ) { |
@@ -20,16 +20,16 @@ discard block |
||
20 | 20 | |
21 | 21 | return $data ? $this->decode($data) : null; |
22 | 22 | } |
23 | - public function getValue($name,$key) |
|
23 | + public function getValue($name, $key) |
|
24 | 24 | { |
25 | - if ( is_null($key) ) { |
|
25 | + if (is_null($key)) { |
|
26 | 26 | throw new \Exception('value is null'); |
27 | 27 | } |
28 | 28 | $data = $this->cache->get($this->prefix . $name); |
29 | - if ( ! $data ) return null; |
|
29 | + if ( ! $data) return null; |
|
30 | 30 | |
31 | 31 | $data = $this->decode($data); |
32 | - if ( isset($data[$key]) === false ) { |
|
32 | + if (isset($data[$key]) === false) { |
|
33 | 33 | throw new \Exception('value is not found. key=' . $key); |
34 | 34 | } |
35 | 35 | return $data[$key]; |
@@ -37,28 +37,28 @@ discard block |
||
37 | 37 | public function getNames() |
38 | 38 | { |
39 | 39 | $names = $this->cache->get($this->name_list); |
40 | - if ( $names ) { |
|
40 | + if ($names) { |
|
41 | 41 | $names = $this->decode($names); |
42 | 42 | } else { |
43 | 43 | $names = []; |
44 | 44 | } |
45 | 45 | return $names; |
46 | 46 | } |
47 | - public function set($name,$data) |
|
47 | + public function set($name, $data) |
|
48 | 48 | { |
49 | - $this->cache->forever($this->prefix . $name,$this->encode($data)); |
|
49 | + $this->cache->forever($this->prefix . $name, $this->encode($data)); |
|
50 | 50 | $this->addNames($name); |
51 | 51 | } |
52 | 52 | public function importYaml($yaml_data) |
53 | 53 | { |
54 | 54 | $data = Yaml::parse($yaml_data); |
55 | - if ( is_array($data) === false) { |
|
55 | + if (is_array($data) === false) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | - foreach ( $data as $name => $rec ) { |
|
59 | - foreach ( $rec as $key => $values ) { |
|
60 | - if ( isset($values['value']) === true) { |
|
61 | - $this->set($name . '_' . $key,$values['value']); |
|
58 | + foreach ($data as $name => $rec) { |
|
59 | + foreach ($rec as $key => $values) { |
|
60 | + if (isset($values['value']) === true) { |
|
61 | + $this->set($name . '_' . $key, $values['value']); |
|
62 | 62 | } else { |
63 | 63 | throw new \Exception('valueが見つかりません。key=' . $key); |
64 | 64 | } |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | public function clear() |
69 | 69 | { |
70 | 70 | $names = $this->getNames(); |
71 | - if ( count($names) > 0 ) { |
|
72 | - foreach ( $names as $name ) { |
|
71 | + if (count($names) > 0) { |
|
72 | + foreach ($names as $name) { |
|
73 | 73 | $this->cache->forget($this->prefix . $name); |
74 | 74 | } |
75 | 75 | } |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | protected function addNames($name) |
79 | 79 | { |
80 | 80 | $names = $this->getNames(); |
81 | - if ( in_array($name,$names) === false ) { |
|
81 | + if (in_array($name, $names) === false) { |
|
82 | 82 | $names[] = $name; |
83 | 83 | } |
84 | - $this->cache->forever($this->name_list,$this->encode($names)); |
|
84 | + $this->cache->forever($this->name_list, $this->encode($names)); |
|
85 | 85 | } |
86 | 86 | protected function encode($data) |
87 | 87 | { |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | protected $valiable; |
14 | 14 | protected $filesystem; |
15 | 15 | |
16 | - public function __construct(Valiable $valiable,Filesystem $filesystem) |
|
16 | + public function __construct(Valiable $valiable, Filesystem $filesystem) |
|
17 | 17 | { |
18 | 18 | $this->valiable = $valiable; |
19 | 19 | $this->filesystem = $filesystem; |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | $path = storage_path('app/sonar_valiables'); |
26 | 26 | $files = $this->filesystem->allFiles($path); |
27 | 27 | |
28 | - if ( is_array($files) === false || count($files) == 0 ) { |
|
28 | + if (is_array($files) === false || count($files) == 0) { |
|
29 | 29 | throw new \Exception('ファイルが見つかりません。[' . $path . ']'); |
30 | 30 | } |
31 | - foreach ( $files as $rec ) { |
|
32 | - if ( preg_match("/\.yml$/",$rec->getPathname()) ) { |
|
31 | + foreach ($files as $rec) { |
|
32 | + if (preg_match("/\.yml$/", $rec->getPathname())) { |
|
33 | 33 | $this->valiable->importYaml($this->filesystem->get($rec->getPathname())); |
34 | 34 | } |
35 | 35 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | protected function registerValiableBuilder() |
40 | 40 | { |
41 | - $this->app->singleton('sonar_valiable',function($app) { |
|
41 | + $this->app->singleton('sonar_valiable', function($app) { |
|
42 | 42 | return new Valiable($app['cache.store']); |
43 | 43 | }); |
44 | 44 | } |