1
0
mirror of https://github.com/Chouchen/ShikiryuRSS.git synced 2024-05-20 06:31:30 +02:00
ShikiryuRSS/src/Entity/Channel/Image.php

62 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace Shikiryu\SRSS\Entity\Channel;
2023-04-12 15:28:38 +02:00
use ReflectionException;
use Shikiryu\SRSS\Entity\SRSSElement;
use Shikiryu\SRSS\Validator\HasValidator;
use Shikiryu\SRSS\Validator\Validator;
class Image extends HasValidator implements SRSSElement
{
/**
2023-04-17 14:28:01 +02:00
* @validate required
* @validate url
* @format url
*/
2023-04-17 14:28:01 +02:00
protected ?string $url = null;
/**
2023-04-17 14:28:01 +02:00
* @validate required
* @validate nohtml
* @format nohtml
*/
2023-04-17 14:28:01 +02:00
protected ?string $title = null;
/**
2023-04-17 14:28:01 +02:00
* @validate required
* @validate url
* @format url
*/
2023-04-17 14:28:01 +02:00
protected ?string $link = null;
/**
2023-04-17 14:28:01 +02:00
* @validate int
* @format int
* @validate max 144
*/
2023-04-17 14:28:01 +02:00
protected int $width = 88; // Maximum value for width is 144, default value is 88.
/**
2023-04-17 14:28:01 +02:00
* @format int
* @validate int
* @validate max 400
*/
2023-04-17 14:28:01 +02:00
protected int $height = 31; //Maximum value for height is 400, default value is 31.
2023-04-17 14:28:01 +02:00
/**
* @var string
* @format html
*/
protected string $description;
public function isValid(): bool
{
try {
return (new Validator())->isObjectValid($this);
2023-04-12 15:28:38 +02:00
} catch (ReflectionException) {
return false;
}
}
public function toArray(): array
{
return get_object_vars($this);
}
}