validate($value); return $this->outputValidValue($value); } /** * Validate given value * * @param integer $value * @return void */ protected function validate(int $value): void { if ($value < $this->minValue || $value > $this->maxValue) { throw new InvalidArgumentException('Value ' . $value . ' is out of bounds (' . $this->minValue . '..' . $this->maxValue . ')'); } } /** * Serialize a valid value into a character * * @param integer $value * @return string */ abstract protected function outputValidValue(int $value): string; }