Добрый день товарищи знатоки, решил сделать класс для проверки входящих параметров, выглядит от примерно так:
public function __construct($parameter)
{
$this->parameter = $parameter;
$this->value = @$_REQUEST[$parameter];
return $this;
}
public function max($count)
{
if ($this->value !== null && $this->value >= $count) {
die($error ?? "parameter $this->parameter should be less $count");
}
return $this;
}
public function min($count)
{
if ($this->value !== null && $this->value <= $count) {
die($error ?? "parameter $this->parameter should be more $count");
}
return $this;
}
public function int($error = null) {
if ($this->value !== null && (int)$this->value != $this->value) {
die($error ?? "parameter $this->parameter should be integer");
}
return $this;
}
А вот так пишется:
$aboba = params::get("aboba")->int()->max(10)->min(8);
Но возникает проблема. Класс всегда возвращает себя, а хочется, чтобы после последней проверки он возвращал значение параметра. Так вот, можно ли как-то определить, что проверка min, или любая другая является последней?