* @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\DTO; if (!defined('_PS_VERSION_')) { exit; } use PrestaShop\Module\PsxDesign\VO\Color\VariableType; use Symfony\Component\HttpFoundation\ParameterBag; class PsxDesignColorData { /** * @var int */ private $id; /** * @var int */ private $paletteId; /** * @var string */ private $title; /** * @var string */ private $variableName; /** * @var array|null */ private $properties; /** * @var string */ private $variableType; /** * @var string */ private $value; private function __construct(ParameterBag $data) { $this->id = $data->getInt('id'); $this->paletteId = $data->getInt('palette_id'); $this->title = $data->get('title'); $this->variableName = $data->get('variable_name') ?? ''; $this->properties = $data->get('properties') ?? null; $this->variableType = (new VariableType($data->get('variable_type') ?? ''))->getType(); $this->value = $data->get('value'); } /** * @param array $color * * @return PsxDesignColorData */ public static function createFromRequest(array $color): self { return new self(new ParameterBag($color)); } /** * @return int */ public function getId(): int { return $this->id; } /** * @return int */ public function getPaletteId(): int { return $this->paletteId; } /** * @return string */ public function getTitle() { return $this->title; } /** * @return string */ public function getVariableName(): string { return $this->variableName; } /** * @return array|null */ public function getProperties(): ?array { return $this->properties; } /** * @return string */ public function getVariableType(): string { return $this->variableType; } /** * @return string */ public function getValue(): string { return $this->value; } /** * @return array */ public function toArray(): array { return [ 'id' => $this->getId(), 'palette_id' => $this->getPaletteId(), 'title' => $this->getTitle(), 'variable_name' => $this->getVariableName(), 'properties' => $this->getProperties(), 'variable_type' => $this->getVariableType(), 'value' => $this->getValue(), ]; } }