| Conditions | 3 |
| Paths | 1 |
| Total Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | protected function getHostsWithChecks() |
||
| 24 | { |
||
| 25 | $hosts = HostRepository::all(); |
||
| 26 | $result = $hosts->map( |
||
| 27 | function (Host $host) { |
||
| 28 | $checks = $host->checks->map( |
||
|
|
|||
| 29 | function (Check $check) { |
||
| 30 | return $check->type; |
||
| 31 | } |
||
| 32 | )->toArray(); |
||
| 33 | |||
| 34 | $result = [ |
||
| 35 | 'name' => $host->name, |
||
| 36 | 'ssh_user' => $host->ssh_user, |
||
| 37 | 'checks' => $checks, |
||
| 38 | ]; |
||
| 39 | if ($host->port) { |
||
| 40 | $result['port'] = $host->port; |
||
| 41 | } |
||
| 42 | if ($host->ip) { |
||
| 43 | $result['ip'] = $host->ip; |
||
| 44 | } |
||
| 45 | |||
| 46 | return $result; |
||
| 47 | } |
||
| 48 | )->toArray(); |
||
| 49 | |||
| 50 | return $result; |
||
| 51 | } |
||
| 52 | } |
||
| 53 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.