. */ namespace Plugin\ActivityPub\Util\Type\Validator; use Exception; use Plugin\ActivityPub\Util\Type\Extended\Activity\Question; use Plugin\ActivityPub\Util\Type\Util; use Plugin\ActivityPub\Util\Type\ValidatorTools; /** * \Plugin\ActivityPub\Util\Type\Validator\AnyOfValidator is a dedicated * validator for anyOf attribute. */ class AnyOfValidator extends ValidatorTools { /** * Validate an ANYOF attribute value * * @param mixed $value * @param mixed $container An object * * @throws Exception * * @return bool * * @todo Choices can contain Indirect references. * This validation should validate this kind of usage. */ public function validate(mixed $value, mixed $container): bool { // Validate that container is a Question type Util::subclassOf($container, Question::class, true); // A collection if (!is_array($value)) { return false; } if (!count($value)) { return false; } return $this->validateObjectCollection( $value, $this->getQuestionAnswerValidator() ); } }