1 | <?php |
||
11 | final class JmsPropertyMapper implements PropertyMapperInterface |
||
12 | { |
||
13 | /** @var MetadataFactoryInterface */ |
||
14 | private $factory; |
||
15 | /** @var PropertyNamingStrategyInterface */ |
||
16 | private $strategy; |
||
17 | |||
18 | /** |
||
19 | * JmsPropertyMapper constructor. |
||
20 | * |
||
21 | * @param MetadataFactoryInterface $factory |
||
22 | * @param PropertyNamingStrategyInterface $strategy |
||
23 | */ |
||
24 | 2 | public function __construct(MetadataFactoryInterface $factory, PropertyNamingStrategyInterface $strategy) |
|
29 | |||
30 | /** {@inheritdoc} */ |
||
31 | 2 | public function getEntityProperty($className, $apiProperty) |
|
32 | { |
||
33 | 2 | $metadata = $this->getMetadata($className); |
|
34 | |||
35 | 2 | foreach ($metadata->propertyMetadata as $propertyMetadata) { |
|
36 | /** @var PropertyMetadata $propertyMetadata */ |
||
37 | 2 | if ($this->getPropertyName($propertyMetadata) === $apiProperty) { |
|
38 | 2 | return $propertyMetadata->reflection ? $propertyMetadata->reflection->getName() : null; |
|
39 | } |
||
40 | 2 | } |
|
41 | |||
42 | return null; |
||
43 | } |
||
44 | |||
45 | /** {@inheritdoc} */ |
||
46 | public function getApiProperty($className, $objectProperty) |
||
56 | |||
57 | /** {@inheritdoc} */ |
||
58 | public function getApiProperties($className) |
||
71 | |||
72 | /** {@inheritdoc} */ |
||
73 | public function getEntityProperties($className) |
||
74 | { |
||
75 | $metadata = $this->getMetadata($className); |
||
76 | |||
77 | $objectProperties = []; |
||
78 | |||
79 | foreach ($metadata->propertyMetadata as $propertyMetadata) { |
||
80 | /** @var PropertyMetadata $propertyMetadata */ |
||
81 | if (null !== $propertyMetadata->reflection) { |
||
82 | $objectProperties[] = $propertyMetadata->reflection->getName(); |
||
83 | } |
||
84 | } |
||
85 | |||
86 | return $objectProperties; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @param $className |
||
91 | * |
||
92 | * @return \Metadata\ClassHierarchyMetadata|\Metadata\MergeableClassMetadata|null |
||
93 | * @throws MapperException |
||
94 | */ |
||
95 | 2 | private function getMetadata($className) |
|
105 | |||
106 | /** |
||
107 | * @param PropertyMetadata $propertyMetadata |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 2 | private function getPropertyName(PropertyMetadata $propertyMetadata) |
|
115 | } |
||
116 |