32 public const PAGE_LENGTH_HARD_LIMIT_BYTES = Limits::INT16_MAX;
33 public const PHOTO_NAME_LENGTH_HARD_LIMIT_BYTES = Limits::INT16_MAX;
36 private string $photoName;
41 private static function checkLength(
string $string,
string $name,
int $maxLength) :
void{
42 if(strlen($string) > $maxLength){
43 throw new \InvalidArgumentException(sprintf(
"$name must be at most %d bytes, but have %d bytes", $maxLength, strlen($string)));
47 public function __construct(
string $text,
string $photoName =
""){
48 self::checkLength($text,
"Text", self::PAGE_LENGTH_HARD_LIMIT_BYTES);
49 self::checkLength($photoName,
"Photo name", self::PHOTO_NAME_LENGTH_HARD_LIMIT_BYTES);
50 Utils::checkUTF8($text);
52 $this->photoName = $photoName;
55 public function getText() :
string{
59 public function getPhotoName() :
string{
60 return $this->photoName;