self::MAX_WIDTH) { throw new \DomainException(sprintf('Width `%s` is out of range.', $width)); } $this->width = $width; } /** * @param float $meters * @return DormerInnerWidth */ public static function fromMeters(float $meters) : DormerInnerWidth { return new self((int)($meters*100)); } /** * @param int $centimeters * @return DormerInnerWidth */ public static function fromCentimeters(int $centimeters) : DormerInnerWidth { return new self($centimeters); } /** * @return int */ public function toCentimeters() : int { return $this->width; } /** * @return float */ public function toMeters() : float { return number_format($this->width/100, Meter::METERS_DECIMALS, Meter::METERS_DECIMAL_SEPARATOR, Meter::METERS_THOUSAND_SEPARATOR); } }