| Total Complexity | 6 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | trait ServerMessage |
||
| 9 | { |
||
| 10 | protected array $attributes = []; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @return array |
||
| 14 | */ |
||
| 15 | 3 | public function getAttributes(): array |
|
| 16 | { |
||
| 17 | 3 | return $this->attributes; |
|
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param string $attribute |
||
| 22 | * @param mixed $default |
||
| 23 | * |
||
| 24 | * @return mixed |
||
| 25 | */ |
||
| 26 | 2 | public function getAttribute($attribute, $default = null) |
|
| 27 | { |
||
| 28 | 2 | if (false === array_key_exists($attribute, $this->attributes)) { |
|
| 29 | 2 | return $default; |
|
| 30 | } |
||
| 31 | |||
| 32 | 2 | return $this->attributes[$attribute]; |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param string $attribute |
||
| 37 | * @param mixed $value |
||
| 38 | * |
||
| 39 | * @return $this |
||
| 40 | */ |
||
| 41 | 3 | public function withAttribute($attribute, $value) |
|
| 45 | } |
||
| 46 | |||
| 47 | 2 | public function withoutAttribute($attribute) |
|
| 56 | } |
||
| 57 | } |
||
| 58 |