/** * @return mixed */ public function getMap() { $reflectionClass = new \ReflectionClass($this->entity); $properties = $reflectionClass->getProperties(); $annotations = new Annotations($reflectionClass); $data = []; foreach ($properties as $property) { $type = $annotations->getAttributeType($property->getName()); $value = $this->getEntityValue($property->getName()); $data[$property->getName()] = $this->mappingFactory->make($type)->toArray($value); } return $data; }
/** * @param array $data * @param string $type * @return mixed * @throws InvalidAttributeType */ protected function getFieldValue(array $data, string $type) { return $this->mappingFactory->make($type)->toAttribute($data); }
public function testShouldThrowExceptionForInvalidTypes() { $this->expectException(InvalidAttributeType::class); $factory = new Factory(); $factory->make('foo'); }