From 6d354e6a7791026b4a45e5e20963b10ed1a8bfbe Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 17 Jul 2020 15:32:14 +0400 Subject: Added credit entity Signed-off-by: Valentin Popov --- src/Entities/Program/CreditEntity.php | 89 +++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/Entities/Program/CreditEntity.php (limited to 'src/Entities/Program') diff --git a/src/Entities/Program/CreditEntity.php b/src/Entities/Program/CreditEntity.php new file mode 100644 index 0000000..f7088ea --- /dev/null +++ b/src/Entities/Program/CreditEntity.php @@ -0,0 +1,89 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Entities\Program + */ +final class CreditEntity { + /** + * @var string + */ + private string $name; + + /** + * @var string + */ + private string $type; + + /** + * @param array $payload + */ + private function __construct(array $payload) { + $this->name = $payload['name']; + $this->type = $payload['type']; + } + + /** + * @param array $payload + * + * @return \EPGService\Entities\Program\CreditEntity + * + * @throws \RuntimeException + */ + public static function create(array $payload): CreditEntity { + if (!is_string($payload['name'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['type'])) { + throw new RuntimeException('blah-blah-blah'); + } + + return new CreditEntity($payload); + } + + /** + * @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'); + } +} -- cgit v1.2.3