/** * Checks if the required parameters are set and the ones that make no sense given the * snaktype value are not set. */ private function validateParameters(array $params) { if (!$this->modificationHelper->validateStatementGuid($params['claim'])) { $this->errorReporter->dieError('Invalid claim guid', 'invalid-guid'); } if (!isset($params['snakhash'])) { if (!isset($params['snaktype'])) { $this->errorReporter->dieError('When creating a new qualifier (ie when not providing a snakhash) a snaktype should be specified', 'param-missing'); } if (!isset($params['property'])) { $this->errorReporter->dieError('When creating a new qualifier (ie when not providing a snakhash) a property should be specified', 'param-missing'); } } if (isset($params['snaktype']) && $params['snaktype'] === 'value' && !isset($params['value'])) { $this->errorReporter->dieError('When setting a qualifier that is a PropertyValueSnak, the value needs to be provided', 'param-missing'); } }
/** * Validates the parameters and returns the EntityId to act upon on success * * @param array $params * * @return EntityId */ private function getEntityId(array $params) { $entityId = null; foreach ($params['claim'] as $guid) { if (!$this->modificationHelper->validateStatementGuid($guid)) { $this->errorReporter->dieError("Invalid claim guid {$guid}", 'invalid-guid'); } if (is_null($entityId)) { $entityId = $this->guidParser->parse($guid)->getEntityId(); } else { if (!$this->guidParser->parse($guid)->getEntityId()->equals($entityId)) { $this->errorReporter->dieError('All claims must belong to the same entity', 'invalid-guid'); } } } if (is_null($entityId)) { $this->errorReporter->dieError('Could not find an entity for the claims', 'invalid-guid'); } return $entityId; }
/** * @param array $params */ private function validateParameters(array $params) { if (!$this->modificationHelper->validateStatementGuid($params['claim'])) { $this->errorReporter->dieError('Invalid claim guid', 'invalid-guid'); } }