/** * @param \Hynage\ORM\Entity\Field|string $field * @param mixed $value * @return \Hynage\ORM\Entity * @throws Entity\InvalidDefinitionException */ public function setValue($field, $value) { if (!$field instanceof Field) { $field = static::getFieldByName($field); } $property = $field->getProperty(); $reflectionClass = new \ReflectionClass(get_called_class()); if (!$reflectionClass->hasProperty($property)) { throw new Entity\InvalidDefinitionException('No such field: ' . $field->getName()); } $this->{$property} = $value; return $this; }