/** * Преобразование объекта в строку. * @return string */ public function __toString() { $result = ''; $attributes = []; foreach ($this->_attributes as $data) { $attributes[$data['name']] = $data['value']; } $reflection = new \ReflectionClass($this); foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $reflectionProperty) { $propName = $reflectionProperty->name; $attributes[$propName] = $this->{$propName}; } ksort($attributes); foreach ($attributes as $attributeName => $attributeValue) { $result .= ', ' . StringHelper::printVar($attributeName) . '=>' . StringHelper::printVar($attributeValue); } return 'Object(' . $this->className() . '){' . trim($result, ', ') . '}'; }
public function __construct($attributeName, $filter, $previous = null) { $filter = StringHelper::strCrop(StringHelper::printVar($filter), 50); parent::__construct('Filter \'' . $filter . '\' for attribute \'' . $attributeName . '\' is wrong.', 1016, $previous); }