Skip to content

Commit a346940

Browse files
[Autocomplete] Simplified get*MetaData methods
1 parent d569f4f commit a346940

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/Autocomplete/src/Doctrine/EntityMetadata.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,8 @@ public function getPropertyMetadata(string $propertyName): array
6060
public function getFieldMetadata(string $propertyName): array
6161
{
6262
if (\array_key_exists($propertyName, $this->metadata->fieldMappings)) {
63-
$metadata = $this->metadata->fieldMappings[$propertyName];
64-
65-
// In doctrine/orm:^3.0; $metadata will be a FieldMapping object
66-
if (!\is_array($metadata)) {
67-
return (array) $metadata;
68-
}
69-
70-
return $metadata;
63+
// Cast to array, because in doctrine/orm:^3.0; $metadata will be a FieldMapping object
64+
return (array) $this->metadata->fieldMappings[$propertyName];
7165
}
7266

7367
throw new \InvalidArgumentException(sprintf('The "%s" field does not exist in the "%s" entity.', $propertyName, $this->metadata->getName()));
@@ -81,14 +75,8 @@ public function getFieldMetadata(string $propertyName): array
8175
public function getAssociationMetadata(string $propertyName): array
8276
{
8377
if (\array_key_exists($propertyName, $this->metadata->associationMappings)) {
84-
$metadata = $this->metadata->associationMappings[$propertyName];
85-
86-
// In doctrine/orm:^3.0; $metadata will be an AssociationMapping object
87-
if (!\is_array($metadata)) {
88-
return (array) $metadata;
89-
}
90-
91-
return $metadata;
78+
// Cast to array, because in doctrine/orm:^3.0; $metadata will be an AssociationMapping object
79+
return (array) $this->metadata->associationMappings[$propertyName];
9280
}
9381

9482
throw new \InvalidArgumentException(sprintf('The "%s" field does not exist in the "%s" entity.', $propertyName, $this->metadata->getName()));

0 commit comments

Comments
 (0)