public function getOperation() { if (!$this->valueOption->hasValue()) { return new DummyOperation(); } return new FilterOperation($this->field, $this->operator, $this->getValue()); }
public function attachToCompound(Compound $root, $prepend = false) { // prepend component that will render results $root->children()->add(new DataView(function () { if ($this->inputOption->hasValue()) { $this->renderCsv(); } }), true); parent::attachToCompound($root, $prepend); }
public function test() { // existing value in input + default $a = new InputOption('a', ['a' => 'A', 'e' => 'E'], 'default'); self::assertEquals('a', $a->getKey()); self::assertEquals('A', $a->getValue()); self::assertEquals('A', $a->getInputValue()); self::assertEquals('default', $a->getDefaultValue()); self::assertEquals(true, $a->hasValue()); // no value in input + default $b = new InputOption('b', ['a' => 'A', 'e' => 'E'], 'default'); self::assertEquals('default', $b->getValue()); self::assertEquals(null, $b->getInputValue()); self::assertEquals('default', $b->getDefaultValue()); self::assertEquals(true, $b->hasValue()); // no value in input + no default $c = new InputOption('c', ['a' => 'A', 'e' => 'E']); self::assertEquals(false, $c->hasValue()); // existing value in input + no default $e = new InputOption('e', ['a' => 'A', 'e' => 'E']); self::assertEquals(true, $e->hasValue()); self::assertEquals(null, $e->getDefaultValue()); }
private function validateInput() { return $this->fieldOption->hasValue() && array_key_exists($this->fieldOption->getValue(), $this->fields) && $this->directionOption->hasValue() && in_array($this->directionOption->getValue(), [SortOperation::ASC, SortOperation::DESC], true); }