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