| Conditions | 5 |
| Paths | 6 |
| Total Lines | 29 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 24 | public function reset(Endpoint ...$presents) : array |
||
| 25 | { |
||
| 26 | $changes = []; |
||
| 27 | |||
| 28 | $current = []; |
||
| 29 | |||
| 30 | foreach ($presents as $endpoint) { |
||
| 31 | $current[$epn = $endpoint->id()] = $endpoint; |
||
| 32 | |||
| 33 | // if exists |
||
| 34 | if (isset($this->current[$epn])) { |
||
| 35 | unset($this->current[$epn]); |
||
| 36 | continue; |
||
| 37 | } |
||
| 38 | |||
| 39 | // mark join |
||
| 40 | $changes[] = new Changed(Events::JOIN, $endpoint); |
||
| 41 | } |
||
| 42 | |||
| 43 | if ($this->current) { |
||
|
|
|||
| 44 | foreach ($this->current as $endpoint) { |
||
| 45 | // mark leave |
||
| 46 | $changes[] = new Changed(Events::LEAVE, $endpoint); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | $this->current = $current; |
||
| 51 | |||
| 52 | return $changes; |
||
| 53 | } |
||
| 55 |
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.