/** * @param $value */ public function __construct($value) { if (!is_int($value)) { throw new InvalidTypeException($value, ['integer']); } parent::__construct($value); }
/** * @param double $value */ public function __construct($value, $round = null) { if (!filter_var($value, FILTER_VALIDATE_FLOAT)) { throw new InvalidTypeException($value, ['float']); } $value = $round ? $this->round($value, $round) : $value; $this->round = $round; parent::__construct($value); }
/** * @param $value * @param int $leading */ public function __construct($value, $leading = 2) { parent::__construct(str_pad($value, strlen((string) $value) + $leading, "0", STR_PAD_LEFT)); }