| Total Complexity | 4 |
| Total Lines | 22 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class LinkItem implements MetadataItemContract, \Stringable |
||
| 8 | { |
||
| 9 | public function __construct(protected string $rel, protected string $href, protected array $attr = []) |
||
| 10 | { |
||
| 11 | } |
||
| 12 | |||
| 13 | public function __toString(): string |
||
| 14 | { |
||
| 15 | if (! $this->attr) { |
||
|
|
|||
| 16 | return '<link rel="'.e($this->rel).'" href="'.e($this->href).'">'; |
||
| 17 | } |
||
| 18 | |||
| 19 | $attributes = collect($this->attr)->map(function ($value, $key) { |
||
| 20 | return e($key).'="'.e($value).'"'; |
||
| 21 | })->implode(' '); |
||
| 22 | |||
| 23 | return '<link rel="'.e($this->rel).'" href="'.e($this->href).'" '.$attributes.'>'; |
||
| 24 | } |
||
| 25 | |||
| 26 | public function uniqueKey(): string |
||
| 29 | } |
||
| 30 | } |
||
| 31 |
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.