. */ namespace Plugin\ActivityPub\Util\Type\Validator; use Exception; use Plugin\ActivityPub\Util\Type\Core\Collection; use Plugin\ActivityPub\Util\Type\Util; use Plugin\ActivityPub\Util\Type\ValidatorInterface; /** * \Plugin\ActivityPub\Util\Type\Validator\CurrentValidator is a dedicated * validator for current attribute. */ class CurrentValidator implements ValidatorInterface { /** * Validate a current attribute value * * @param mixed $value * @param mixed $container * * @throws Exception * * @return bool */ public function validate(mixed $value, mixed $container): bool { // Container must be a Collection Util::subclassOf($container, Collection::class, true); // URL if (Util::validateUrl($value)) { return true; } // Link or CollectionPage return Util::validateLink($value) || Util::validateCollectionPage($value); } }