Skip to content

Commit 0cdb9e1

Browse files
committed
Removing strict check on id properties
1 parent e52a4b2 commit 0cdb9e1

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

src/Mapping/MappingFactory.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,12 @@ private static function getSelfUrl(array &$mappedClass)
9595
/**
9696
* @param array $mappedClass
9797
*
98-
* @throws MappingException
99-
*
10098
* @return mixed
10199
*/
102100
private static function getIdProperties(array &$mappedClass)
103101
{
104-
if (empty($mappedClass['id_properties'])) {
105-
throw new MappingException(
106-
'Could not find "id_properties" property with data . This is required in order to make the resource to be reachable.'
107-
);
108-
}
109102

110-
return $mappedClass['id_properties'];
103+
return (!empty($mappedClass['id_properties']))? $mappedClass['id_properties'] : [];
111104
}
112105

113106
/**

tests/Mapping/MappingFactoryTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,6 @@ public function testItWillThrowExceptionIfArrayHasNoClassKey()
6161
MappingFactory::fromArray($mappedClass);
6262
}
6363

64-
public function testItWillThrowExceptionIfArrayHasNoIdPropertiesKey()
65-
{
66-
$this->setExpectedException(MappingException::class);
67-
$mappedClass = ['class' => 'Post', 'id_properties' => [], 'urls' => ['self' => 'some/url']];
68-
MappingFactory::fromArray($mappedClass);
69-
}
7064

7165
public function testItWillThrowExceptionIfArrayHasNoSelfUrlKey()
7266
{

0 commit comments

Comments
 (0)