/** * @param string $name * @param $value * @param \Closure $callbackBefore * @throws Exception */ protected final function setProperty($name, $value, $callbackBefore = null) { if (is_callable($callbackBefore)) { $callbackBefore($value); } if (property_exists($this, $name)) { if (is_object($value) || is_null($value)) { $this->{$name} = $value; } else { $this->{$name} = (string) $value; } return; } throw new Exception(ErrorMessages::getNonExistentPropertyMessage($name, get_class($this))); }