/** * Set option boolean value * * @param boolean $value * @throws \InvalidArgumentException */ public function setValue($value) { if (!is_bool($value)) { throw new InvalidArgumentException('Boolean required'); } parent::setValue($value); }
/** * Set password generator option. * * @param string $option * @param array $optionSettings * * @return $this * @throws InvalidOptionTypeException */ public function setOption($option, $optionSettings) { $type = isset($optionSettings['type']) ? $optionSettings['type'] : ''; $this->options[$option] = Option::createFromType($type, $optionSettings); if ($this->options[$option] === null) { throw new InvalidOptionTypeException('Invalid Option Type'); } return $this; }
/** * Set option integer value. * * @param int $value * * @throws \InvalidArgumentException */ public function setValue($value) { if (!is_integer($value)) { throw new InvalidArgumentException('Integer required'); } if ($this->minRange > $value || $this->maxRange < $value) { throw new InvalidArgumentException('Invalid Value'); } parent::setValue($value); }
/** * Set option string value. * * @param string $value * * @throws \InvalidArgumentException */ public function setValue($value) { if (!is_string($value)) { throw new InvalidArgumentException('String required'); } if ($this->minRange > strlen($value) || $this->maxRange < strlen($value)) { throw new InvalidArgumentException('Invalid Value'); } parent::setValue($value); }
public function testCreateFromTypeNull() { $this->assertNull(Option::createFromType('fail')); }