/**
  * @inheritdoc
  */
 public function relationshipNotAcceptable(ResourceIdentifierInterface $identifier, $relationshipKey = null, $error = null)
 {
     $base = $this->repository->errorWithPointer(self::RELATIONSHIP_NOT_ACCEPTABLE, $relationshipKey ? P::relationship($relationshipKey) : P::data(), ['type' => $identifier->getType(), 'id' => $identifier->getId()]);
     $errors = new MutableErrorCollection();
     /** @var MutableErrorInterface $err */
     foreach (MutableErrorCollection::cast($error ?: $base) as $err) {
         $add = clone $base;
         $errors->add($add->merge($err));
     }
     return $errors;
 }
 /**
  * @param ResourceInterface $resource
  * @return bool
  */
 protected function validateId(ResourceInterface $resource)
 {
     /** If expecting an id, one must be provided */
     if (!is_null($this->expectedId) && !$resource->has(ResourceInterface::ID)) {
         $this->addError($this->errorFactory->memberRequired(ResourceInterface::ID, P::data()));
         return false;
     }
     /** If expecting an id, must match the one we're expecting */
     if (!is_null($this->expectedId) && $this->expectedId != $resource->getId()) {
         $this->addError($this->errorFactory->resourceUnsupportedId($this->expectedId, $resource->getId()));
         return false;
     }
     return true;
 }
 /**
  * @param ResourceIdentifierInterface $identifier
  * @param string|null $key
  * @return bool
  */
 protected function validateIdentifier(ResourceIdentifierInterface $identifier, $key = null)
 {
     $valid = true;
     /** Must have a type */
     if (!$identifier->hasType()) {
         $this->addError($this->errorFactory->memberRequired(ResourceIdentifierInterface::TYPE, $key ? P::relationshipData($key) : P::data()));
         $valid = false;
     } elseif (!$this->isSupportedType($identifier->getType())) {
         $this->addError($this->errorFactory->relationshipUnsupportedType($this->expectedTypes, $identifier->getType(), $key));
         $valid = false;
     }
     /** Must have an id */
     if (!$identifier->hasId()) {
         $this->addError($this->errorFactory->memberRequired(ResourceIdentifierInterface::ID, $key ? P::relationshipId($key) : P::data()));
         $valid = false;
     }
     return $valid;
 }