* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ declare(strict_types=1); namespace PrestaShop\Module\PsxDesign\VO\Logo; if (!defined('_PS_VERSION_')) { exit; } use PrestaShop\Module\PsxDesign\Exception\PsxDesignLogoImportException; final class LogoType { public const TEXT = 'text'; public const IMAGE = 'image'; private const ALLOWED_TYPES = [self::TEXT, self::IMAGE]; /** * @var string */ private $type; /** * @param string $type * * @throws PsxDesignLogoImportException */ public function __construct(string $type) { $this->assertIsValidType($type); $this->type = $type; } /** * @return string */ public function getValue(): string { return $this->type; } /** * @param string $type * * @throws PsxDesignLogoImportException */ private function assertIsValidType(string $type): void { if (!in_array($type, self::ALLOWED_TYPES)) { throw new PsxDesignLogoImportException('Svg type is not allowed for email, invoice logo', PsxDesignLogoImportException::INVALID_FORMAT); } } }