From f1d6258633b88200556880130d0faf9ef6b6ea5a Mon Sep 17 00:00:00 2001 From: Irfan Date: Tue, 17 Oct 2023 14:03:34 +0500 Subject: [PATCH] fixes #535 --- src/Model/Common/Title.php | 12 ++++++------ src/Parser/Common/AlternativeTitleParser.php | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Model/Common/Title.php b/src/Model/Common/Title.php index af3de042..c1a2820d 100644 --- a/src/Model/Common/Title.php +++ b/src/Model/Common/Title.php @@ -19,15 +19,15 @@ class Title private string $type; /** - * @var string + * @var string|null */ - private string $title; + private ?string $title; /** - * @param string $title + * @param string|null $title * @param string $type */ - public function __construct(string $type, string $title) + public function __construct(string $type, ?string $title) { $this->type = $type; $this->title = $title; @@ -42,9 +42,9 @@ public function getType(): string } /** - * @return string + * @return string|null */ - public function getTitle(): string + public function getTitle(): ?string { return $this->title; } diff --git a/src/Parser/Common/AlternativeTitleParser.php b/src/Parser/Common/AlternativeTitleParser.php index 16d2f751..8473ecd5 100644 --- a/src/Parser/Common/AlternativeTitleParser.php +++ b/src/Parser/Common/AlternativeTitleParser.php @@ -17,7 +17,7 @@ class AlternativeTitleParser implements ParserInterface /** * @var Crawler */ - private $crawler; + private Crawler $crawler; /** * EpisodeListItemParser constructor. @@ -35,9 +35,10 @@ public function __construct(Crawler $crawler) */ public function getModel(): array { - [$type, $title] = explode(': ', $this->crawler->text(), 2); + [$type, $title] = explode(':', $this->crawler->text(), 2); + if ($type !== 'Synonyms') { - return [new Title($type, $title)]; + return [new Title($type, JString::cleanse($title))]; } $titles = explode(', ', $title);