diff --git a/src/Document.php b/src/Document.php index 32fdccb..925f7c7 100644 --- a/src/Document.php +++ b/src/Document.php @@ -108,11 +108,11 @@ public function setApiMeta(iterable $meta): void public function setIncluded(ResourceObject ...$resources): void { if (null === $this->data) { - throw new \LogicException('Document with no data cannot contain included resources'); + throw new \DomainException('Document with no data cannot contain included resources'); } foreach ($resources as $resource) { if (isset($this->included[(string) $resource->toIdentifier()])) { - throw new \LogicException("Resource {$resource->toIdentifier()} is already included"); + throw new \DomainException("Resource {$resource->toIdentifier()} is already included"); } $this->included[(string) $resource->toIdentifier()] = $resource; } @@ -150,7 +150,7 @@ private function enforceFullLinkage(): void continue 2; } } - throw new \LogicException("Full linkage is required for {$included->toIdentifier()}"); + throw new \DomainException("Full linkage is required for {$included->toIdentifier()}"); } } } diff --git a/src/Document/Resource/ResourceObject.php b/src/Document/Resource/ResourceObject.php index bb631dc..0cfeabf 100644 --- a/src/Document/Resource/ResourceObject.php +++ b/src/Document/Resource/ResourceObject.php @@ -40,13 +40,13 @@ public function setMeta(iterable $meta) public function setAttribute(string $name, $value) { if ($this->isReservedName($name)) { - throw new \InvalidArgumentException("Can not use a reserved name '$name'"); + throw new \DomainException("Can not use a reserved name '$name'"); } if (! isValidMemberName($name)) { throw new \OutOfBoundsException("Invalid member name '$name'"); } if (isset($this->relationships[$name])) { - throw new \LogicException("Field '$name' already exists in relationships"); + throw new \DomainException("Field '$name' already exists in relationships"); } $this->attributes[$name] = $value; } @@ -54,13 +54,13 @@ public function setAttribute(string $name, $value) public function setRelationship(string $name, Relationship $relationship) { if ($this->isReservedName($name)) { - throw new \InvalidArgumentException("Can not use a reserved name '$name'"); + throw new \DomainException("Can not use a reserved name '$name'"); } if (! isValidMemberName($name)) { throw new \OutOfBoundsException("Invalid member name '$name'"); } if (isset($this->attributes[$name])) { - throw new \LogicException("Field '$name' already exists in attributes"); + throw new \DomainException("Field '$name' already exists in attributes"); } $this->relationships[$name] = $relationship; } diff --git a/test/Document/CompoundDocumentTest.php b/test/Document/CompoundDocumentTest.php index 20e3910..5789f26 100644 --- a/test/Document/CompoundDocumentTest.php +++ b/test/Document/CompoundDocumentTest.php @@ -164,7 +164,7 @@ public function testOfficialDocsExample() } /** - * @expectedException \LogicException + * @expectedException \DomainException * @expectedExceptionMessage Full linkage is required for apples:1 * @dataProvider documentsWithoutFullLinkage * @param Document $doc @@ -269,7 +269,7 @@ public function testIncludedResourceMayBeIdentifiedByAnotherLinkedResource() /** * A compound document MUST NOT include more than one resource object for each type and id pair. - * @expectedException \LogicException + * @expectedException \DomainException * @expectedExceptionMessage Resource apples:1 is already included */ public function testCanNotBeManyIncludedResourcesWithEqualIdentifiers() @@ -283,7 +283,7 @@ public function testCanNotBeManyIncludedResourcesWithEqualIdentifiers() /** * If a document does not contain a top-level data key, the included member MUST NOT be present either. - * @expectedException \LogicException + * @expectedException \DomainException * @expectedExceptionMessage Document with no data cannot contain included resources */ public function testIncludedMustOnlyBePresentWithData() diff --git a/test/Document/Resource/ResourceFieldsTest.php b/test/Document/Resource/ResourceFieldsTest.php index fc06e8b..9e25d6f 100644 --- a/test/Document/Resource/ResourceFieldsTest.php +++ b/test/Document/Resource/ResourceFieldsTest.php @@ -21,7 +21,7 @@ class ResourceFieldsTest extends TestCase { /** - * @expectedException \LogicException + * @expectedException \DomainException * @expectedExceptionMessage Field 'foo' already exists in attributes */ public function testCanNotSetRelationshipIfAttributeExists() @@ -32,7 +32,7 @@ public function testCanNotSetRelationshipIfAttributeExists() } /** - * @expectedException \LogicException + * @expectedException \DomainException * @expectedExceptionMessage Field 'foo' already exists in relationships */ public function testCanNotSetAttributeIfRelationshipExists() @@ -44,7 +44,7 @@ public function testCanNotSetAttributeIfRelationshipExists() /** * @param string $name - * @expectedException \InvalidArgumentException + * @expectedException \DomainException * @expectedExceptionMessage Can not use a reserved name * @dataProvider reservedAttributeNames */ @@ -56,7 +56,7 @@ public function testAttributeCanNotHaveReservedNames(string $name) /** * @param string $name - * @expectedException \InvalidArgumentException + * @expectedException \DomainException * @expectedExceptionMessage Can not use a reserved name * @dataProvider reservedAttributeNames */