| Total Complexity | 2 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | class GetOperator extends BaseOperator |
||
| 22 | {
|
||
| 23 | /** |
||
| 24 | * Name of the key from which value will be returned. |
||
| 25 | * |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | public $name; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Default value to be returned if that key was not found. |
||
| 32 | * |
||
| 33 | * @var mixed |
||
| 34 | */ |
||
| 35 | public $default; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Passes data from operator configuration. |
||
| 39 | * |
||
| 40 | * Depending on the operator this data can contain other sub-expressions which need to be parsed using |
||
| 41 | * ExpressionParser |
||
| 42 | * |
||
| 43 | * @param array $config Expressions to be processed |
||
| 44 | * @see ExpressionParser |
||
| 45 | */ |
||
| 46 | 10 | public function configure(array $config) |
|
| 47 | {
|
||
| 48 | 10 | $this->setName($config[0] ?? 'unknown'); |
|
| 49 | |||
| 50 | 10 | $this->name = $config[1] ?? ''; |
|
| 51 | 10 | $this->default = $config['default'] ?? null; |
|
| 52 | 10 | } |
|
| 53 | |||
| 54 | /** |
||
| 55 | * Evaluates one value. |
||
| 56 | * |
||
| 57 | * @param ValueParser $value Value to be evaluated |
||
| 58 | * @return mixed Evaluation result |
||
| 59 | */ |
||
| 60 | 9 | public function evaluate(ValueParser $value) |
|
| 63 | } |
||
| 64 | |||
| 65 | } |