Passed
Push — master ( e13190...a8c1c0 )
by Yuichi
03:18 queued 41s
created
src/Valiable.php 3 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -43,11 +43,19 @@
 block discarded – undo
43 43
         }
44 44
         return $names;
45 45
     }
46
+
47
+    /**
48
+     * @param string $name
49
+     */
46 50
     public function set($name,$data)
47 51
     {
48 52
         $this->cache->forever($this->prefix . $name,$this->encode($data));
49 53
         $this->addNames($name);
50 54
     }
55
+
56
+    /**
57
+     * @param string $yaml_data
58
+     */
51 59
     public function importYaml($yaml_data)
52 60
     {
53 61
         $data = Yaml::parse($yaml_data);
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
         return $data ? $this->decode($data) : null;
21 21
     }
22
-    public function getValue($name,$key)
22
+    public function getValue($name, $key)
23 23
     {
24
-        if ( is_null($key) ) {
24
+        if (is_null($key)) {
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) return null;
29 29
 
30 30
         $data = $this->decode($data);
31
-        if ( isset($data[$key]) === false  ) {
31
+        if (isset($data[$key]) === false) {
32 32
             throw new \Exception('value is not found. key=' . $key);
33 33
         }
34 34
         return $data[$key];
@@ -36,25 +36,25 @@  discard block
 block discarded – undo
36 36
     public function getNames()
37 37
     {
38 38
         $names = $this->cache->get($this->name_list);
39
-        if ( $names ) {
39
+        if ($names) {
40 40
             $names = $this->decode($names);
41 41
         } else {
42 42
             $names = [];
43 43
         }
44 44
         return $names;
45 45
     }
46
-    public function set($name,$data)
46
+    public function set($name, $data)
47 47
     {
48
-        $this->cache->forever($this->prefix . $name,$this->encode($data));
48
+        $this->cache->forever($this->prefix . $name, $this->encode($data));
49 49
         $this->addNames($name);
50 50
     }
51 51
     public function importYaml($yaml_data)
52 52
     {
53 53
         $data = Yaml::parse($yaml_data);
54
-        foreach ( $data as $name => $rec ) {
55
-            foreach ( $rec as $key => $values ) {
56
-                if ( isset($values['value'] ) ) {
57
-                    $this->set($name . '_' . $key,$values['value']);
54
+        foreach ($data as $name => $rec) {
55
+            foreach ($rec as $key => $values) {
56
+                if (isset($values['value'])) {
57
+                    $this->set($name . '_' . $key, $values['value']);
58 58
                 } else {
59 59
                     throw new \Exception('valueが見つかりません。key=' . $key);
60 60
                 }
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
     public function clear()
65 65
     {
66 66
         $names = $this->getNames();
67
-        if ( count($names) > 0 ) {
68
-            foreach ( $names as $name ) {
67
+        if (count($names) > 0) {
68
+            foreach ($names as $name) {
69 69
                 $this->cache->forget($this->prefix . $name);
70 70
             }
71 71
         }
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
     protected function addNames($name)
75 75
     {
76 76
         $names = $this->getNames();
77
-        if ( in_array($name,$names) === false ) {
77
+        if (in_array($name, $names) === false) {
78 78
             $names[] = $name;
79 79
         }
80
-        $this->cache->forever($this->name_list,$this->encode($names));
80
+        $this->cache->forever($this->name_list, $this->encode($names));
81 81
     }
82 82
     protected function encode($data)
83 83
     {
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@
 block discarded – undo
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  ) {
Please login to merge, or discard this patch.
src/Console/ValiableListCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Console/ValiableImportCommand.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
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,9 +25,9 @@  discard block
 block discarded – undo
25 25
         $path = storage_path('app/sonar_valiables');
26 26
         $files = $this->filesystem->allFiles($path);
27 27
 
28
-        if ( is_array($files) && count($files) > 0 ) {
29
-            foreach ( $this->filesystem->allFiles($path) as $rec ) {
30
-                if ( preg_match("/\.yml$/",$rec->getPathname()) ) {
28
+        if (is_array($files) && count($files) > 0) {
29
+            foreach ($this->filesystem->allFiles($path) as $rec) {
30
+                if (preg_match("/\.yml$/", $rec->getPathname())) {
31 31
                     $this->valiable->importYaml($this->filesystem->get($rec->getPathname()));
32 32
                 }
33 33
             }
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use Illuminate\Support\Str;
3 3
 
4
-function val($param,$key)
4
+function val($param, $key)
5 5
 {
6
-    app('Sonar\Valiable\Valiable')->getValue($param,$key);
6
+    app('Sonar\Valiable\Valiable')->getValue($param, $key);
7 7
 }
8 8
 
9 9
 function val_all($param)
@@ -11,17 +11,17 @@  discard block
 block discarded – undo
11 11
     app('Sonar\Valiable\Valiable')->get($param);
12 12
 }
13 13
 
14
-function val_table($table,$param,$key)
14
+function val_table($table, $param, $key)
15 15
 {
16
-    if ( strtolower($table) != $table ) {
16
+    if (strtolower($table) != $table) {
17 17
         $table = Str::plural(Str::camel($table));
18 18
     }
19
-    app('Sonar\Valiable\Valiable')->getValue($table . '_' . $param,$key);
19
+    app('Sonar\Valiable\Valiable')->getValue($table . '_' . $param, $key);
20 20
 }
21 21
 
22
-function val_table_all($table,$param)
22
+function val_table_all($table, $param)
23 23
 {
24
-    if ( strtolower($table) != $table ) {
24
+    if (strtolower($table) != $table) {
25 25
         $table = Str::plural(Str::camel($table));
26 26
     }
27 27
     app('Sonar\Valiable\Valiable')->get($table . '_' . $param);
Please login to merge, or discard this patch.
src/functions_app.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 use Illuminate\Contracts\Container\Container;
3 3
 
4
-if (! function_exists('app')) {
4
+if ( ! function_exists('app')) {
5 5
     /**
6 6
      * Get the available container instance.
7 7
      *
Please login to merge, or discard this patch.
src/functions_include.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! function_exists('val') ) {
3
+if ( ! function_exists('val')) {
4 4
     require_once __DIR__ . '/functions.php';
5 5
 }
Please login to merge, or discard this patch.