Passed
Push — master ( 5fe6af...53ff23 )
by Yuichi
02:29
created
src/TreeStructureTrait.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,8 +19,12 @@  discard block
 block discarded – undo
19 19
         $tree = isset($this->tree) ? $this->tree : [];
20 20
 
21 21
         foreach ($data as $rec) {
22
-            if (is_object($rec) === false) throw new Exception('data record must be object.');
23
-            if (isset($rec->id) === false) throw new Exception('data record object does not have property => "id".');
22
+            if (is_object($rec) === false) {
23
+                throw new Exception('data record must be object.');
24
+            }
25
+            if (isset($rec->id) === false) {
26
+                throw new Exception('data record object does not have property => "id".');
27
+            }
24 28
             if (isset($rec->parent_id) === false || ! $rec->parent_id) {
25 29
                 $rec->children = [];
26 30
                 $tree[$rec->id] = $rec;
@@ -48,9 +52,15 @@  discard block
 block discarded – undo
48 52
         $tree = isset($this->tree) ? $this->tree : [];
49 53
         foreach ($tree as &$rec) {
50 54
             foreach ($count_data as $count) {
51
-                if (isset($rec->id) === false) throw new Exception('data record object does not have property => "id".');
52
-                if (isset($count->id) === false) throw new Exception('count data record object does not have property => "id".');
53
-                if (isset($count->count) === false) throw new Exception('count data record object does not have property => "count".');
55
+                if (isset($rec->id) === false) {
56
+                    throw new Exception('data record object does not have property => "id".');
57
+                }
58
+                if (isset($count->id) === false) {
59
+                    throw new Exception('count data record object does not have property => "id".');
60
+                }
61
+                if (isset($count->count) === false) {
62
+                    throw new Exception('count data record object does not have property => "count".');
63
+                }
54 64
                 if ($rec->id == $count->id) {
55 65
                     $rec->count = $count->count;
56 66
                 }
Please login to merge, or discard this patch.