From 37fb5985b8774274d489b8c003bc92b29a0dc9c2 Mon Sep 17 00:00:00 2001 From: Badraxas Date: Wed, 24 Jan 2024 00:18:46 +0100 Subject: [PATCH] Use type AdsTxtLineInterface instead of AbstractAdsTxtLine as return type (#4) * V3 * Set coding style * Change type AdsTxtLineInterface to AbstractAdsTxtLine --- src/Interfaces/ParserInterface.php | 4 +++- src/Parsers/CommentParser.php | 4 ++-- src/Parsers/InvalidParser.php | 4 ++-- src/Parsers/RecordParser.php | 5 +++-- src/Parsers/VariableParser.php | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Interfaces/ParserInterface.php b/src/Interfaces/ParserInterface.php index 79fd678..d6861de 100644 --- a/src/Interfaces/ParserInterface.php +++ b/src/Interfaces/ParserInterface.php @@ -2,7 +2,9 @@ namespace Badraxas\Adstxt\Interfaces; +use Badraxas\Adstxt\Lines\AbstractAdsTxtLine; + interface ParserInterface { - public function parse(string $line): AdsTxtLineInterface; + public function parse(string $line): AbstractAdsTxtLine; } diff --git a/src/Parsers/CommentParser.php b/src/Parsers/CommentParser.php index 0894128..fcedb6b 100644 --- a/src/Parsers/CommentParser.php +++ b/src/Parsers/CommentParser.php @@ -2,13 +2,13 @@ namespace Badraxas\Adstxt\Parsers; -use Badraxas\Adstxt\Interfaces\AdsTxtLineInterface; use Badraxas\Adstxt\Interfaces\ParserInterface; +use Badraxas\Adstxt\Lines\AbstractAdsTxtLine; use Badraxas\Adstxt\Lines\Comment; class CommentParser implements ParserInterface { - public function parse(string $line): AdsTxtLineInterface + public function parse(string $line): AbstractAdsTxtLine { $raw = $line; $line = trim(mb_strcut($line, 1)); diff --git a/src/Parsers/InvalidParser.php b/src/Parsers/InvalidParser.php index c38e78f..e984c03 100644 --- a/src/Parsers/InvalidParser.php +++ b/src/Parsers/InvalidParser.php @@ -2,14 +2,14 @@ namespace Badraxas\Adstxt\Parsers; -use Badraxas\Adstxt\Interfaces\AdsTxtLineInterface; use Badraxas\Adstxt\Interfaces\ParserInterface; +use Badraxas\Adstxt\Lines\AbstractAdsTxtLine; use Badraxas\Adstxt\Lines\Comment; use Badraxas\Adstxt\Lines\Invalid; class InvalidParser implements ParserInterface { - public function parse(string $line): AdsTxtLineInterface + public function parse(string $line): AbstractAdsTxtLine { $raw = $line; diff --git a/src/Parsers/RecordParser.php b/src/Parsers/RecordParser.php index 050aae3..94f2633 100644 --- a/src/Parsers/RecordParser.php +++ b/src/Parsers/RecordParser.php @@ -2,15 +2,15 @@ namespace Badraxas\Adstxt\Parsers; -use Badraxas\Adstxt\Interfaces\AdsTxtLineInterface; use Badraxas\Adstxt\Interfaces\ParserInterface; +use Badraxas\Adstxt\Lines\AbstractAdsTxtLine; use Badraxas\Adstxt\Lines\Comment; use Badraxas\Adstxt\Lines\Invalid; use Badraxas\Adstxt\Lines\Record; class RecordParser implements ParserInterface { - public function parse(string $line): AdsTxtLineInterface + public function parse(string $line): AbstractAdsTxtLine { $raw = $line; $comment = null; @@ -23,6 +23,7 @@ public function parse(string $line): AdsTxtLineInterface } $exploded_line = explode(',', $line); + $exploded_line = array_map('trim', $exploded_line); $fieldsCount = count($exploded_line); diff --git a/src/Parsers/VariableParser.php b/src/Parsers/VariableParser.php index b2ca811..d2022a4 100644 --- a/src/Parsers/VariableParser.php +++ b/src/Parsers/VariableParser.php @@ -2,15 +2,15 @@ namespace Badraxas\Adstxt\Parsers; -use Badraxas\Adstxt\Interfaces\AdsTxtLineInterface; use Badraxas\Adstxt\Interfaces\ParserInterface; +use Badraxas\Adstxt\Lines\AbstractAdsTxtLine; use Badraxas\Adstxt\Lines\Comment; use Badraxas\Adstxt\Lines\Invalid; use Badraxas\Adstxt\Lines\Variable; class VariableParser implements ParserInterface { - public function parse(string $line): AdsTxtLineInterface + public function parse(string $line): AbstractAdsTxtLine { $comment = null;