* @license http://www.apache.org/licenses/LICENSE-2.0 * @package EPGService\Entities */ class GenreEntity { /** * @var int */ protected int $id; /** * @var string */ protected string $lang; /** * @var string */ protected string $name; /** * @var string */ protected string $version; /** * @param int $id * @param string $lang * @param string $name * @param string $version */ protected function __construct(int $id, string $lang, string $name, string $version) { $this->id = $id; $this->lang = $lang; $this->name = $name; $this->version = $version; } public static function create(array $payload): GenreEntity { if (!is_int($payload['id'])) { throw new RuntimeException('blah-blah-blah'); } if (!is_string($payload['lang'])) { throw new RuntimeException('blah-blah-blah'); } if (!is_string($payload['name'])) { throw new RuntimeException('blah-blah-blah'); } if (!is_string($payload['version'])) { throw new RuntimeException('blah-blah-blah'); } return new GenreEntity($payload['id'], $payload['lang'], $payload['name'], $payload['version']); } /** * @param string $name * * @return mixed */ public function __get(string $name) { return $this->$name; } /** * @param string $name * @param mixed $value * * @throws \RuntimeException */ public function __set(string $name, $value) { throw new RuntimeException('blah-blah-blah'); } }