| Total Complexity | 11 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | trait SitesTrait |
||
| 14 | { |
||
| 15 | /** @var array|null $sites */ |
||
| 16 | protected $sites = []; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @return array|null |
||
| 20 | */ |
||
| 21 | public function getSites(): ?array |
||
| 22 | { |
||
| 23 | return $this->sites; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param array|null $sites |
||
| 28 | */ |
||
| 29 | public function setSites(?array $sites): void |
||
| 30 | { |
||
| 31 | $this->sites = $sites; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param array|null $sites |
||
| 36 | */ |
||
| 37 | public function addSites(?array $sites) |
||
| 38 | { |
||
| 39 | if (!$sites) { |
||
|
|
|||
| 40 | return ; |
||
| 41 | } |
||
| 42 | |||
| 43 | foreach ($sites as $site) { |
||
| 44 | $this->addSite($site); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param array $site |
||
| 50 | */ |
||
| 51 | public function addSite(array $site) |
||
| 62 | } |
||
| 63 | } |
||
| 64 | } |
||
| 65 |
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.