| Conditions | 5 |
| Paths | 8 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 5.0729 |
| Changes | 0 | ||
| 1 | <?php |
||
| 61 | public function getByRoles(string $roles) |
||
| 62 | { |
||
| 63 | if (is_string($roles)) { |
||
| 64 | 18 | $roles = array_map('trim', explode(',', $roles)); |
|
| 65 | 17 | } |
|
| 66 | 17 | ||
| 67 | $hosts = []; |
||
| 68 | foreach ($this->hosts as $host) { |
||
| 69 | foreach ($host->get('roles', []) as $role) { |
||
| 70 | if (in_array($role, $roles, true)) { |
||
| 71 | 20 | $hosts[] = $host; |
|
| 72 | 1 | } |
|
| 73 | 1 | } |
|
| 74 | } |
||
| 75 | |||
| 76 | return $hosts; |
||
| 77 | } |
||
| 78 | } |
||
| 79 |