. */ namespace SP\Repositories\Plugin; use SP\Core\Exceptions\NoSuchPropertyException; use SP\DataModel\HydratableInterface; use SP\Util\Util; /** * Class PluginData * * @package SP\Repositories\Plugin */ final class PluginDataModel implements HydratableInterface { /** * @var string */ private $name; /** * @var int */ private $itemId; /** * @var string */ private $data; /** * @return string */ public function getName(): string { return $this->name; } /** * @param string $name */ public function setName(string $name) { $this->name = $name; } /** * @return int */ public function getItemId(): int { return (int)$this->itemId; } /** * @param int $itemId */ public function setItemId(int $itemId) { $this->itemId = $itemId; } /** * @return string */ public function getData(): string { return $this->data; } /** * @param string $data */ public function setData(string $data) { $this->data = $data; } /** * @param string $class * * @param string $property * * @return mixed|null * @throws NoSuchPropertyException */ public function hydrate(string $class = null, string $property = 'data') { if (property_exists($this, $property)) { if ($this->data !== null) { return $class !== null ? Util::unserialize($class, $this->data) : unserialize($this->data); } return null; } throw new NoSuchPropertyException($property); } }