From aee28b34500562311ff7eac6359cc771a4d11fd1 Mon Sep 17 00:00:00 2001 From: mathiaspalmqvist <51116221+mathiaspalmqvist@users.noreply.github.com> Date: Fri, 4 Jul 2025 19:21:52 +0000 Subject: [PATCH] Fix styling --- Tests/ArchTest.php | 2 +- Tests/CisionTest.php | 5 ++--- Tests/Pest.php | 2 +- Tests/TestCase.php | 2 +- src/Cision.php | 12 ++++++------ src/CisionServiceProvider.php | 1 - src/Support/HtmlCleaner.php | 11 +++++++---- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Tests/ArchTest.php b/Tests/ArchTest.php index e5be658..87fb64c 100644 --- a/Tests/ArchTest.php +++ b/Tests/ArchTest.php @@ -2,4 +2,4 @@ arch('it will not use debugging functions') ->expect(['dd', 'dump', 'ray']) - ->each->not->toBeUsed(); \ No newline at end of file + ->each->not->toBeUsed(); diff --git a/Tests/CisionTest.php b/Tests/CisionTest.php index 8cdb18b..da78677 100644 --- a/Tests/CisionTest.php +++ b/Tests/CisionTest.php @@ -1,8 +1,7 @@ Http::response(file_get_contents(__DIR__.'/Fixtures/article.html')), ]); - $cision = new Cision(); + $cision = new Cision; $content = $cision->fetchContent('https://news.cision.com/se/example/r/test,c123456'); expect($content)->toHaveKeys(['header', 'published_at', 'content']); diff --git a/Tests/Pest.php b/Tests/Pest.php index 45c3e5c..2423448 100644 --- a/Tests/Pest.php +++ b/Tests/Pest.php @@ -2,4 +2,4 @@ use Mattitja\Cision\Tests\TestCase; -uses(TestCase::class)->in(__DIR__); \ No newline at end of file +uses(TestCase::class)->in(__DIR__); diff --git a/Tests/TestCase.php b/Tests/TestCase.php index 7d25c9e..141d203 100644 --- a/Tests/TestCase.php +++ b/Tests/TestCase.php @@ -34,4 +34,4 @@ class TestCase extends Orchestra } */ } -} \ No newline at end of file +} diff --git a/src/Cision.php b/src/Cision.php index 1bff21f..d829d00 100755 --- a/src/Cision.php +++ b/src/Cision.php @@ -3,10 +3,10 @@ namespace Mattitja\Cision; use Carbon\Carbon; -use Illuminate\Support\Facades\Http; use Illuminate\Http\Client\Response; -use Symfony\Component\DomCrawler\Crawler; +use Illuminate\Support\Facades\Http; use Mattitja\Cision\Support\HtmlCleaner; +use Symfony\Component\DomCrawler\Crawler; class Cision { @@ -15,7 +15,7 @@ class Cision /** * Constructor that accepts a slug identifier for the feed. */ - public function __construct(string $slug = null) + public function __construct(?string $slug = null) { $this->slug = $slug ?? env('LARAVEL_CISION_FEED_SLUG', ''); } @@ -105,7 +105,7 @@ class Cision $query['m'] = $type; } - return Http::get('https://news.cision.com/se/ListItems?' . http_build_query($query)); + return Http::get('https://news.cision.com/se/ListItems?'.http_build_query($query)); } protected function parseResponse(string $data, int $page): array|false @@ -116,7 +116,7 @@ class Cision // Suppress XML parsing warnings libxml_use_internal_errors(true); - $xml = simplexml_load_string($data, "SimpleXMLElement", LIBXML_NOCDATA); + $xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA); libxml_clear_errors(); if ($xml === false) { @@ -128,7 +128,7 @@ class Cision $rows = json_decode($json, true); // Validate structure - if (!isset($rows['channel']['item'])) { + if (! isset($rows['channel']['item'])) { return false; } diff --git a/src/CisionServiceProvider.php b/src/CisionServiceProvider.php index 80caf79..54cf451 100644 --- a/src/CisionServiceProvider.php +++ b/src/CisionServiceProvider.php @@ -4,7 +4,6 @@ namespace Mattitja\Cision; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; -use Mattitja\Cision\Commands\CisionCommand; class CisionServiceProvider extends PackageServiceProvider { diff --git a/src/Support/HtmlCleaner.php b/src/Support/HtmlCleaner.php index dfac263..fafa1d8 100644 --- a/src/Support/HtmlCleaner.php +++ b/src/Support/HtmlCleaner.php @@ -2,9 +2,9 @@ namespace Mattitja\Cision\Support; +use DOMElement; use DOMNode; use DOMText; -use DOMElement; class HtmlCleaner { @@ -17,7 +17,7 @@ class HtmlCleaner return $node->wholeText; } - if (!($node instanceof DOMElement)) { + if (! ($node instanceof DOMElement)) { return null; } @@ -35,6 +35,7 @@ class HtmlCleaner return '
'; } } + return null; } @@ -52,9 +53,11 @@ class HtmlCleaner $html = $node->C14N(); $isItalic = str_starts_with(trim($html), '" . trim($inner) . "

"; + + return "".trim($inner).'

'; } - return "<{$tag}>" . trim($inner) . ""; + + return "<{$tag}>".trim($inner).""; } if (in_array($tag, $allowedInline)) {