Fix styling
This commit is contained in:
1 parent
db87a5d45f
commit
aee28b3450
7 files changed
+18
-17
No files matched your search
+1
-1
@@ -2,4 +2,4 @@
|
||||
|
||||
arch('it will not use debugging functions')
|
||||
->expect(['dd', 'dump', 'ray'])
|
||||
->each->not->toBeUsed();
|
||||
->each->not->toBeUsed();
|
||||
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Mattitja\Cision\Cision;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Mattitja\Cision\Cision;
|
||||
|
||||
it('can fetch press releases from the RSS feed', function () {
|
||||
Http::fake([
|
||||
@@ -25,7 +24,7 @@ it('can fetch and parse full article content', function () {
|
||||
'news.cision.com/*' => 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']);
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@
|
||||
|
||||
use Mattitja\Cision\Tests\TestCase;
|
||||
|
||||
uses(TestCase::class)->in(__DIR__);
|
||||
uses(TestCase::class)->in(__DIR__);
|
||||
+1
-1
@@ -34,4 +34,4 @@ class TestCase extends Orchestra
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Mattitja\Cision;
|
||||
|
||||
use Spatie\LaravelPackageTools\Package;
|
||||
use Spatie\LaravelPackageTools\PackageServiceProvider;
|
||||
use Mattitja\Cision\Commands\CisionCommand;
|
||||
|
||||
class CisionServiceProvider extends PackageServiceProvider
|
||||
{
|
||||
|
||||
@@ -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 '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -52,9 +53,11 @@ class HtmlCleaner
|
||||
$html = $node->C14N();
|
||||
$isItalic = str_starts_with(trim($html), '<em') || str_starts_with(trim($html), '<i');
|
||||
$class = $isItalic ? ' class="italic"' : '';
|
||||
return "<p{$class}>" . trim($inner) . "</p>";
|
||||
|
||||
return "<p{$class}>".trim($inner).'</p>';
|
||||
}
|
||||
return "<{$tag}>" . trim($inner) . "</{$tag}>";
|
||||
|
||||
return "<{$tag}>".trim($inner)."</{$tag}>";
|
||||
}
|
||||
|
||||
if (in_array($tag, $allowedInline)) {
|
||||
|
||||
Reference in new issue
Block a user