| Total Complexity | 9 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| 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 | $valueArray = []; |
||
| 26 | if (!empty(parent::getValue()) && \in_array($this->operator, ['e', 'n'])) { |
||
| 27 | foreach (\App\Json::decode(parent::getValue()) as $value) { |
||
| 28 | if (!empty($value[$this->operator])) { |
||
| 29 | $valueArray[] = $value[$this->operator]; |
||
| 30 | } |
||
| 31 | } |
||
| 32 | } |
||
| 33 | return $valueArray; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** {@inheritdoc} */ |
||
| 37 | public function operatorE(): bool |
||
| 38 | { |
||
| 39 | return (bool) array_intersect($this->getValue(), explode($this->separator, $this->value)); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** {@inheritdoc} */ |
||
| 43 | public function operatorN(): bool |
||
| 44 | { |
||
| 45 | return (bool) !array_intersect($this->getValue(), explode($this->separator, $this->value)); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** {@inheritdoc} */ |
||
| 49 | public function operatorC(): bool |
||
| 50 | { |
||
| 51 | return $this->operatorE(); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** {@inheritdoc} */ |
||
| 55 | public function operatorK(): bool |
||
| 58 | } |
||
| 59 | } |
||
| 60 |