diff --git a/src/Mapping/MappingFactory.php b/src/Mapping/MappingFactory.php index 5945a03..dfcbf88 100644 --- a/src/Mapping/MappingFactory.php +++ b/src/Mapping/MappingFactory.php @@ -95,19 +95,12 @@ private static function getSelfUrl(array &$mappedClass) /** * @param array $mappedClass * - * @throws MappingException - * * @return mixed */ private static function getIdProperties(array &$mappedClass) { - if (empty($mappedClass['id_properties'])) { - throw new MappingException( - 'Could not find "id_properties" property with data . This is required in order to make the resource to be reachable.' - ); - } - return $mappedClass['id_properties']; + return (!empty($mappedClass['id_properties']))? $mappedClass['id_properties'] : []; } /** diff --git a/tests/Mapping/MappingFactoryTest.php b/tests/Mapping/MappingFactoryTest.php index 6baa724..4bad1f6 100644 --- a/tests/Mapping/MappingFactoryTest.php +++ b/tests/Mapping/MappingFactoryTest.php @@ -61,12 +61,6 @@ public function testItWillThrowExceptionIfArrayHasNoClassKey() MappingFactory::fromArray($mappedClass); } - public function testItWillThrowExceptionIfArrayHasNoIdPropertiesKey() - { - $this->setExpectedException(MappingException::class); - $mappedClass = ['class' => 'Post', 'id_properties' => [], 'urls' => ['self' => 'some/url']]; - MappingFactory::fromArray($mappedClass); - } public function testItWillThrowExceptionIfArrayHasNoSelfUrlKey() {