| Conditions | 5 |
| Paths | 6 |
| Total Lines | 31 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | protected function routing(Service $service) : array |
||
| 27 | { |
||
| 28 | $commands = []; |
||
| 29 | |||
| 30 | $newEndpoints = []; |
||
| 31 | |||
| 32 | foreach ($service->getEndpoints() as $endpoint) { |
||
| 33 | $epn = $endpoint->id(); |
||
| 34 | |||
| 35 | $newEndpoints[$epn] = $endpoint; |
||
| 36 | |||
| 37 | if (isset($this->prevEndpoints[$epn])) { |
||
| 38 | // exists |
||
| 39 | unset($this->prevEndpoints[$epn]); |
||
| 40 | continue; |
||
| 41 | } else { |
||
| 42 | // join |
||
| 43 | $commands[] = new Router(Router::JOIN, $endpoint); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | if ($this->prevEndpoints) { |
||
|
|
|||
| 48 | foreach ($this->prevEndpoints as $endpoint) { |
||
| 49 | // leave |
||
| 50 | $commands[] = new Router(Router::LEAVE, $endpoint); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | $this->prevEndpoints = $newEndpoints; |
||
| 55 | |||
| 56 | return $commands; |
||
| 57 | } |
||
| 59 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.