| @@ -47,35 +47,35 @@ | ||
| 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; | 
| 64 | 64 | } | 
| 65 | - protected function addCount(&$tree,$id,$count,$is_merge) | |
| 65 | + protected function addCount(&$tree, $id, $count, $is_merge) | |
| 66 | 66 |      {
 | 
| 67 | -        foreach ( $tree as $rec ) {
 | |
| 68 | -            if ( $rec->id == $id ) {
 | |
| 69 | -                if( isset($rec->count) ) {
 | |
| 67 | +        foreach ($tree as $rec) {
 | |
| 68 | +            if ($rec->id == $id) {
 | |
| 69 | +                if (isset($rec->count)) {
 | |
| 70 | 70 | $rec->count += $count; | 
| 71 | 71 |                  } else {
 | 
| 72 | 72 | $rec->count = $count; | 
| 73 | 73 | } | 
| 74 | -                if ( isset($rec->parent_id) && $rec->parent_id && $is_merge ) {
 | |
| 75 | - $this->addCount($this->tree,$rec->parent_id,$count,$is_merge); | |
| 74 | +                if (isset($rec->parent_id) && $rec->parent_id && $is_merge) {
 | |
| 75 | + $this->addCount($this->tree, $rec->parent_id, $count, $is_merge); | |
| 76 | 76 | } | 
| 77 | -            } elseif ( count($rec->children) ) {
 | |
| 78 | - $this->addCount($rec->children,$id,$count,$is_merge); | |
| 77 | +            } elseif (count($rec->children)) {
 | |
| 78 | + $this->addCount($rec->children, $id, $count, $is_merge); | |
| 79 | 79 | } | 
| 80 | 80 | } | 
| 81 | 81 | } |