From b95c97fc07bee5c4bcb5d582d8aff9991922aaa1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 16:04:57 +0400 Subject: Added presenter Signed-off-by: Valentin Popov --- src/Presenter/ServicePresenter.php | 92 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 src/Presenter/ServicePresenter.php (limited to 'src/Presenter') diff --git a/src/Presenter/ServicePresenter.php b/src/Presenter/ServicePresenter.php new file mode 100644 index 0000000..f5b1e61 --- /dev/null +++ b/src/Presenter/ServicePresenter.php @@ -0,0 +1,92 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Presenter + */ +final class ServicePresenter { + /** + * @var \EPGService\Environments\ServiceEnvironment + */ + private ServiceEnvironment$environment; + + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + */ + private function __construct(ServiceEnvironment $environment) { + $this->environment = $environment; + } + + /** + * @return \EPGService\Entities\CategoryEntity[] + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception + */ + public function getCategories(): array { + return CategoryRepository::create($this->environment)->get(); + } + + /** + * @return \EPGService\Entities\ChannelEntity[] + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception + */ + public function getChannels(): array { + return ChannelRepository::create($this->environment)->get(); + } + + /** + * @return \EPGService\Entities\GenreEntity[] + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception + */ + public function getGenres(): array { + return GenreRepository::create($this->environment)->get(); + } + + /** + * @param string $channel_id + * @param string $week + * + * @return \EPGService\Entities\ProgramEntity[] + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception + */ + public function getPrograms(string $channel_id, string $week): array { + return ProgramRepository::create($this->environment, $channel_id, $week)->get(); + } +} -- cgit v1.2.3 From bf538eac242e4fc2962e626bfb722fa0638afcb2 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 17:09:12 +0400 Subject: Added create static function Signed-off-by: Valentin Popov --- src/Presenter/ServicePresenter.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Presenter') diff --git a/src/Presenter/ServicePresenter.php b/src/Presenter/ServicePresenter.php index f5b1e61..e3117ed 100644 --- a/src/Presenter/ServicePresenter.php +++ b/src/Presenter/ServicePresenter.php @@ -43,6 +43,15 @@ final class ServicePresenter { $this->environment = $environment; } + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + * + * @return \EPGService\Presenter\ServicePresenter + */ + public static function create(ServiceEnvironment $environment): ServicePresenter { + return new ServicePresenter($environment); + } + /** * @return \EPGService\Entities\CategoryEntity[] * -- cgit v1.2.3