| Conditions | 5 |
| Paths | 7 |
| Total Lines | 27 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 41 | public function aggregates(ResultCollection $results) { |
||
| 42 | $array = array(); |
||
| 43 | foreach($results as $result) { |
||
| 44 | $basename = dirname($result->getFilename()); |
||
| 45 | |||
| 46 | // from 'folder1/folder2/file.php', we want an array with ('folder1', 'folder1/folder2') |
||
| 47 | $namespaces = array_reduce(explode(DIRECTORY_SEPARATOR, $basename), function($v, $e) { |
||
| 48 | array_push($v, ltrim(end($v).DIRECTORY_SEPARATOR.$e, DIRECTORY_SEPARATOR)); |
||
| 49 | return $v; |
||
| 50 | }, array()); |
||
| 51 | |||
| 52 | if($this->depth) { |
||
| 53 | array_splice($namespaces, $this->depth); |
||
| 54 | } |
||
| 55 | |||
| 56 | // merge infos for each namespace in the DirectoryResultCollection |
||
| 57 | foreach($namespaces as $namespace) { |
||
| 58 | |||
| 59 | if(!isset($array[$namespace])) { |
||
| 60 | $array[$namespace] = new ResultCollection(); |
||
| 61 | } |
||
| 62 | |||
| 63 | $array[$namespace]->push($result); |
||
| 64 | } |
||
| 65 | } |
||
| 66 | return $array; |
||
| 67 | } |
||
| 68 | } |