Conditions | 8 |
Paths | 14 |
Total Lines | 15 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 8 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
46 | 4 | public function mergeCount($count_data) |
|
47 | { |
||
48 | 4 | $tree = isset($this->tree) ? $this->tree : []; |
|
49 | 4 | foreach ( $tree as &$rec ) { |
|
50 | 4 | foreach ( $count_data as $count ) { |
|
51 | 4 | if ( isset($rec->id) === false ) throw new Exception('data record object does not have property => "id".'); |
|
52 | 4 | if ( isset($count->id) === false ) throw new Exception('count data record object does not have property => "id".'); |
|
53 | 2 | if ( isset($count->count) === false ) throw new Exception('count data record object does not have property => "count".'); |
|
54 | 1 | if ( $rec->id == $count->id ) { |
|
55 | 1 | $rec->count = $count->count; |
|
56 | 1 | } |
|
57 | 1 | } |
|
58 | 1 | } |
|
59 | 1 | $this->tree = $tree; |
|
60 | 1 | } |
|
61 | } |
||
62 |