aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Entities/ChannelEntity.php29
-rw-r--r--src/Repositories/ChannelRepository.php6
2 files changed, 20 insertions, 15 deletions
diff --git a/src/Entities/ChannelEntity.php b/src/Entities/ChannelEntity.php
index 0d8d3fc..4881722 100644
--- a/src/Entities/ChannelEntity.php
+++ b/src/Entities/ChannelEntity.php
@@ -19,21 +19,22 @@ declare(strict_types = 1);
namespace EPGService\Entities;
+use DateTime;
use RuntimeException;
use function is_string;
/**
- * @property-read string $base_id
- * @property-read string $base_name
- * @property-read string $epg_id
- * @property-read string $geo_data
- * @property-read string $href
- * @property-read string $icon
- * @property-read string $id
- * @property-read string $lang
- * @property-read string $name
- * @property-read string $update_at
- * @property-read string $week
+ * @property-read string $base_id
+ * @property-read string $base_name
+ * @property-read string $epg_id
+ * @property-read string $geo_data
+ * @property-read string $href
+ * @property-read string $icon
+ * @property-read string $id
+ * @property-read string $lang
+ * @property-read string $name
+ * @property-read \DateTime $update_at
+ * @property-read string $week
*
* @copyright Copyright © 2020 “Valentin Popov” <info@valentineus.link>
* @license http://www.apache.org/licenses/LICENSE-2.0
@@ -86,9 +87,9 @@ final class ChannelEntity {
private string $name;
/**
- * @var string
+ * @var \DateTime
*/
- private string $update_at;
+ private DateTime $update_at;
/**
* @var string
@@ -156,7 +157,7 @@ final class ChannelEntity {
throw new RuntimeException('blah-blah-blah');
}
- if (!is_string($payload['update_at'])) {
+ if (!$payload['update_at'] instanceof DateTime) {
throw new RuntimeException('blah-blah-blah');
}
diff --git a/src/Repositories/ChannelRepository.php b/src/Repositories/ChannelRepository.php
index 44eac36..772e4f9 100644
--- a/src/Repositories/ChannelRepository.php
+++ b/src/Repositories/ChannelRepository.php
@@ -19,6 +19,7 @@ declare(strict_types = 1);
namespace EPGService\Repositories;
+use DateTime;
use EPGService\Entities\ChannelEntity;
use EPGService\Environments\ServiceEnvironment;
use EPGService\Parsers\StringParser;
@@ -66,6 +67,7 @@ final class ChannelRepository implements BaseRepository {
*
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \RuntimeException
+ * @throws \Exception
*/
public function get(): array {
$response = $this->client->get(self::METHOD);
@@ -84,6 +86,8 @@ final class ChannelRepository implements BaseRepository {
continue;
}
+ $update = StringParser::get($element->update);
+
$result[] = ChannelEntity::create([
'base_id' => StringParser::get($element->{'base-channel'}),
'base_name' => StringParser::get($element->{'base-channel'}['id']),
@@ -94,7 +98,7 @@ final class ChannelRepository implements BaseRepository {
'id' => StringParser::get($element['id']),
'lang' => StringParser::get($element->{'display-name'}['lang']),
'name' => StringParser::get($element->{'base-channel'}),
- 'update_at' => StringParser::get($element->update),
+ 'update_at' => new DateTime($update),
'week' => StringParser::get($element->week),
]);
}