/** * @see ChangeOp::apply * * @param Entity $entity * @param Summary|null $summary * * @throws ChangeOpException */ public function apply(Entity $entity, Summary $summary = null) { if ($this->statement->getGuid() === null) { $this->statement->setGuid($this->guidGenerator->newGuid($entity->getId())); } $guid = $this->guidParser->parse($this->statement->getGuid()); if ($this->guidValidator->validate($guid->getSerialization()) === false) { throw new ChangeOpException("Claim does not have a valid GUID"); } elseif (!$entity->getId()->equals($guid->getEntityId())) { throw new ChangeOpException("Claim GUID invalid for given entity"); } $this->applyClaimToEntity($entity, $summary); }
/** * @see ChangeOp::apply * * @param EntityDocument $entity * @param Summary|null $summary * * @throws ChangeOpException */ public function apply(EntityDocument $entity, Summary $summary = null) { if (!$entity instanceof StatementListHolder) { throw new InvalidArgumentException('$entity must be a StatementListHolder'); } if ($this->statement->getGuid() === null) { $this->statement->setGuid($this->guidGenerator->newGuid($entity->getId())); } $guid = $this->guidParser->parse($this->statement->getGuid()); if ($this->guidValidator->validate($guid->getSerialization()) === false) { throw new ChangeOpException("Claim does not have a valid GUID"); } elseif (!$entity->getId()->equals($guid->getEntityId())) { throw new ChangeOpException("Claim GUID invalid for given entity"); } $this->applyStatementToEntity($entity, $summary); }
/** * @param string $guid * * @throws UsageException * @return bool */ public function validateStatementGuid($guid) { return $this->guidValidator->validate($guid); }