2021-08-25 04:29:26 +09:00
|
|
|
<?php
|
|
|
|
|
2021-10-10 17:26:18 +09:00
|
|
|
declare(strict_types = 1);
|
|
|
|
|
2021-08-25 04:29:26 +09:00
|
|
|
/*
|
|
|
|
* This file is part of the ActivityPhp package.
|
|
|
|
*
|
|
|
|
* Copyright (c) landrok at github.com/landrok
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please see
|
|
|
|
* <https://github.com/landrok/activitypub/blob/master/LICENSE>.
|
|
|
|
*/
|
|
|
|
|
2021-10-05 01:00:58 +09:00
|
|
|
namespace Plugin\ActivityPub\Util\Type\Validator;
|
2021-08-25 04:29:26 +09:00
|
|
|
|
|
|
|
use Exception;
|
2021-10-05 01:00:58 +09:00
|
|
|
use Plugin\ActivityPub\Util\Type\Core\Link;
|
|
|
|
use Plugin\ActivityPub\Util\Type\Extended\Object\Image;
|
|
|
|
use Plugin\ActivityPub\Util\Type\Util;
|
|
|
|
use Plugin\ActivityPub\Util\Type\ValidatorInterface;
|
2021-08-25 04:29:26 +09:00
|
|
|
|
|
|
|
/**
|
2021-10-05 01:00:58 +09:00
|
|
|
* \Plugin\ActivityPub\Util\Type\Validator\HeightValidator is a dedicated
|
2021-08-25 04:29:26 +09:00
|
|
|
* validator for height attribute.
|
|
|
|
*/
|
|
|
|
class HeightValidator implements ValidatorInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Validate height value
|
|
|
|
*
|
|
|
|
* @param mixed $container An object
|
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function validate(mixed $value, mixed $container): bool
|
|
|
|
{
|
|
|
|
// Validate that container is a Link
|
|
|
|
Util::subclassOf($container, [Link::class, Image::class], true);
|
|
|
|
|
|
|
|
// Must be a non-negative integer
|
|
|
|
return Util::validateNonNegativeInteger($value);
|
|
|
|
}
|
|
|
|
}
|