| Total Complexity | 7 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | class MultiEmailField extends BaseField |
||
| 18 | { |
||
| 19 | /** @var string Separator. */ |
||
| 20 | protected $separator = ','; |
||
| 21 | |||
| 22 | /** {@inheritdoc} */ |
||
| 23 | public function getValue(): array |
||
| 24 | { |
||
| 25 | if (!empty(parent::getValue()) && \in_array($this->operator, ['e', 'n'])) { |
||
| 26 | return array_map(fn ($email) => $email['e'], \App\Json::decode(parent::getValue())); |
||
| 27 | } |
||
|
|
|||
| 28 | } |
||
| 29 | |||
| 30 | /** {@inheritdoc} */ |
||
| 31 | public function operatorE(): bool |
||
| 32 | { |
||
| 33 | return (bool) array_intersect($this->getValue(), explode($this->separator, $this->value)); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** {@inheritdoc} */ |
||
| 37 | public function operatorN(): bool |
||
| 38 | { |
||
| 39 | return (bool) !array_intersect($this->getValue(), explode($this->separator, $this->value)); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** {@inheritdoc} */ |
||
| 43 | public function operatorC(): bool |
||
| 44 | { |
||
| 45 | return $this->operatorE(); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** {@inheritdoc} */ |
||
| 49 | public function operatorK(): bool |
||
| 52 | } |
||
| 53 | } |
||
| 54 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: