1 | <?php |
||
12 | final class JmsPropertyMapper implements PropertyMapperInterface |
||
13 | { |
||
14 | /** @var MetadataFactoryInterface */ |
||
15 | private $factory; |
||
16 | /** @var PropertyNamingStrategyInterface */ |
||
17 | private $strategy; |
||
18 | |||
19 | /** |
||
20 | * JmsPropertyMapper constructor. |
||
21 | * |
||
22 | * @param MetadataFactoryInterface $factory |
||
23 | * @param PropertyNamingStrategyInterface $strategy |
||
24 | */ |
||
25 | 5 | public function __construct(MetadataFactoryInterface $factory, PropertyNamingStrategyInterface $strategy) |
|
26 | { |
||
27 | 5 | $this->factory = $factory; |
|
28 | 5 | $this->strategy = $strategy; |
|
29 | 5 | } |
|
30 | |||
31 | /** {@inheritdoc} */ |
||
32 | 4 | public function getEntityProperty($className, $apiProperty) |
|
33 | { |
||
34 | 4 | $metadata = $this->getMetadata($className); |
|
35 | |||
36 | 4 | foreach ($metadata->propertyMetadata as $propertyMetadata) { |
|
37 | /** @var PropertyMetadata $propertyMetadata */ |
||
38 | 4 | if ($this->getPropertyName($propertyMetadata) === $apiProperty) { |
|
39 | 4 | return $propertyMetadata->reflection ? $propertyMetadata->reflection->getName() : null; |
|
40 | } |
||
41 | } |
||
42 | |||
43 | return null; |
||
44 | } |
||
45 | |||
46 | /** {@inheritdoc} */ |
||
47 | public function getApiProperty($className, $objectProperty) |
||
57 | |||
58 | /** {@inheritdoc} */ |
||
59 | public function getApiProperties($className): array |
||
72 | |||
73 | /** {@inheritdoc} */ |
||
74 | public function getEntityProperties($className): array |
||
89 | |||
90 | /** |
||
91 | * @param $className |
||
92 | * |
||
93 | * @return ClassMetadata |
||
94 | * @throws MapperException |
||
95 | */ |
||
96 | 4 | private function getMetadata($className): ClassMetadata |
|
106 | |||
107 | 4 | private function getPropertyName(PropertyMetadata $propertyMetadata): string |
|
111 | } |
||
112 |