@@ -47,17 +47,17 @@ discard block |
||
47 | 47 | unset($rec); |
48 | 48 | } |
49 | 49 | } |
50 | - public function mergeCount($count_data,$is_merge=false) |
|
50 | + public function mergeCount($count_data, $is_merge = false) |
|
51 | 51 | { |
52 | 52 | $tree = isset($this->tree) ? $this->tree : []; |
53 | - foreach ( $count_data as $count ) { |
|
53 | + foreach ($count_data as $count) { |
|
54 | 54 | if (isset($count->id) === false) { |
55 | 55 | throw new Exception('count data record object does not have property => "id".'); |
56 | 56 | } |
57 | 57 | if (isset($count->count) === false) { |
58 | 58 | throw new Exception('count data record object does not have property => "count".'); |
59 | 59 | } |
60 | - $this->addCount($this->tree,$count->id,$count->count,$is_merge); |
|
60 | + $this->addCount($this->tree, $count->id, $count->count, $is_merge); |
|
61 | 61 | |
62 | 62 | } |
63 | 63 | $this->tree = $tree; |
@@ -86,20 +86,20 @@ discard block |
||
86 | 86 | } |
87 | 87 | } |
88 | 88 | */ |
89 | - protected function addCount(&$tree,$id,$count,$is_merge) |
|
89 | + protected function addCount(&$tree, $id, $count, $is_merge) |
|
90 | 90 | { |
91 | - foreach ( $tree as $rec ) { |
|
92 | - if ( $rec->id == $id ) { |
|
93 | - if( isset($rec->count) ) { |
|
91 | + foreach ($tree as $rec) { |
|
92 | + if ($rec->id == $id) { |
|
93 | + if (isset($rec->count)) { |
|
94 | 94 | $rec->count += $count; |
95 | 95 | } else { |
96 | 96 | $rec->count = $count; |
97 | 97 | } |
98 | - if ( isset($rec->parent_id) && $rec->parent_id && $is_merge ) { |
|
99 | - $this->addCount($this->tree,$rec->parent_id,$count,$is_merge); |
|
98 | + if (isset($rec->parent_id) && $rec->parent_id && $is_merge) { |
|
99 | + $this->addCount($this->tree, $rec->parent_id, $count, $is_merge); |
|
100 | 100 | } |
101 | - } elseif ( count($rec->children) ) { |
|
102 | - $this->addCount($rec->children,$id,$count,$is_merge); |
|
101 | + } elseif (count($rec->children)) { |
|
102 | + $this->addCount($rec->children, $id, $count, $is_merge); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |