Fix styling
This commit is contained in:
1 parent
db87a5d45f
commit
aee28b3450
4 files changed
+11
-10
No files matched your search
@@ -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']);
|
||||
|
||||
+4
-4
@@ -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', '');
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -35,6 +35,7 @@ class HtmlCleaner
|
||||
return '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -52,8 +53,10 @@ 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}>";
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user