![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/laminas/laminas-i18n/src/Validator/ |
<?php declare(strict_types=1); namespace Laminas\I18n\Validator; use Laminas\I18n\CountryCode as Country; use Laminas\I18n\Exception\InvalidArgumentException; use Laminas\Validator\AbstractValidator; use function is_string; final class CountryCode extends AbstractValidator { public const NOT_STRING = 'notString'; public const EMPTY_STRING = 'emptyString'; public const INVALID = 'invalid'; /** @var array<string, string> */ protected $messageTemplates = [ self::NOT_STRING => 'Invalid type given. String expected', self::EMPTY_STRING => 'Country codes must be non-empty strings', self::INVALID => '"%value%" is not a valid ISO-3166 country code', ]; public function isValid(mixed $value): bool { if ($value instanceof Country) { return true; } $this->setValue($value); if (! is_string($value)) { $this->error(self::NOT_STRING); return false; } if ($value === '') { $this->error(self::EMPTY_STRING); return false; } try { Country::fromString($value); return true; } catch (InvalidArgumentException) { $this->error(self::INVALID); return false; } } }