type = $type; $this->language = $language; $this->setValue($value); } /** * Get id * * @return int * * @since 1.0.0 */ public function getId() : int { return $this->id; } /** * Set value * * @param int|string|float|\DateTimeInterface $value Value * * @return void * * @since 1.0.0 */ public function setValue($value) : void { if (\is_string($value)) { $this->valueStr = $value; } elseif (\is_int($value)) { $this->valueInt = $value; } elseif (\is_float($value)) { $this->valueDec = $value; } elseif ($value instanceof \DateTimeInterface) { $this->valueDat = $value; } } /** * Get value * * @return null|int|string|float|\DateTimeInterface * * @since 1.0.0 */ public function getValue() : mixed { if (!empty($this->valueStr)) { return $this->valueStr; } elseif (!empty($this->valueInt)) { return $this->valueInt; } elseif (!empty($this->valueDec)) { return $this->valueDec; } elseif ($this->valueDat instanceof \DateTimeInterface) { return $this->valueDat; } return null; } /** * Set language * * @param string $language Language * * @return void * * @since 1.0.0 */ public function setLanguage(string $language) : void { $this->language = $language; } /** * Get language * * @return string * * @since 1.0.0 */ public function getLanguage() : string { return $this->language; } /** * Set country * * @param string $country Country * * @return void * * @since 1.0.0 */ public function setCountry(string $country) : void { $this->country = $country; } /** * Get country * * @return string * * @since 1.0.0 */ public function getCountry() : string { return $this->country; } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'type' => $this->type, 'valueInt' => $this->valueInt, 'valueStr' => $this->valueStr, 'valueDec' => $this->valueDec, 'valueDat' => $this->valueDat, 'isDefault' => $this->isDefault, 'language' => $this->language, 'country' => $this->country, ]; } /** * {@inheritdoc} */ public function jsonSerialize() : mixed { return $this->toArray(); } }