подпись в настройках. */ public const FIXED_LABELS = [ Vat::NONE => 'Без НДС', 'vat0' => 'НДС 0%', 'vat5' => 'НДС 5%', 'vat7' => 'НДС 7%', 'vat10' => 'НДС 10%', 'vat20' => 'НДС 20%', 'vat22' => 'НДС 22%', 'vat105' => 'НДС 5% (расчётная ставка 5/105)', 'vat107' => 'НДС 7% (расчётная ставка 7/107)', 'vat110' => 'НДС 10% (расчётная ставка 10/110)', 'vat120' => 'НДС 20% (расчётная ставка 20/120)', 'vat122' => 'НДС 22% (расчётная ставка 22/122)', ]; /** @var Vat|null */ private $fixed; private function __construct(?Vat $fixed) { $this->fixed = $fixed; } /** * Значение из настроек; пустое, {@see self::PLATFORM} или неизвестное — ставка из PHPShop. */ public static function fromSetting(?string $value): self { $value = (string) $value; return new self(isset(self::FIXED_LABELS[$value]) ? Vat::fromCode($value) : null); } public static function platform(): self { return new self(null); } /** * Фиксированная ставка или null — брать из PHPShop. */ public function getFixed(): ?Vat { return $this->fixed; } public function getValue(): string { return ($this->fixed !== null) ? $this->fixed->getCode() : self::PLATFORM; } /** * Подписи для выпадающего списка: первым — ставка из PHPShop с подписью `$platformLabel`. * * @return array */ public static function labels(string $platformLabel): array { return [self::PLATFORM => $platformLabel] + self::FIXED_LABELS; } }