diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..6714b02 --- /dev/null +++ b/pint.json @@ -0,0 +1,23 @@ +{ + "preset": "laravel", + "rules": { + "no_superfluous_phpdoc_tags": true, + "concat_space": { + "spacing": "one" + }, + "single_quote": true, + "combine_consecutive_issets": true, + "combine_consecutive_unsets": true, + "explicit_string_variable": true, + "global_namespace_import": true, + "single_trait_insert_per_statement": true, + "ordered_traits": true, + "types_spaces": { + "space": "single" + } + }, + "exclude": [ + "lang", + "vendor.nosync" + ] +} \ No newline at end of file diff --git a/src/Facades/SEOManager.php b/src/Facades/SEOManager.php index 5eb7c4e..15680e6 100644 --- a/src/Facades/SEOManager.php +++ b/src/Facades/SEOManager.php @@ -17,4 +17,4 @@ protected static function getFacadeAccessor() { return \RalphJSmit\Laravel\SEO\SEOManager::class; } -} \ No newline at end of file +} diff --git a/src/Models/SEO.php b/src/Models/SEO.php index 94e0051..25fcc9d 100644 --- a/src/Models/SEO.php +++ b/src/Models/SEO.php @@ -19,14 +19,14 @@ public function model(): MorphTo public function prepareForUsage(): SEOData { - if ( method_exists($this->model, 'getDynamicSEOData') ) { + if (method_exists($this->model, 'getDynamicSEOData')) { /** @var SEOData $overrides */ $overrides = $this->model->getDynamicSEOData(); } - if ( method_exists($this->model, 'enableTitleSuffix') ) { + if (method_exists($this->model, 'enableTitleSuffix')) { $enableTitleSuffix = $this->model->enableTitleSuffix(); - } elseif ( property_exists($this->model, 'enableTitleSuffix') ) { + } elseif (property_exists($this->model, 'enableTitleSuffix')) { $enableTitleSuffix = $this->model->enableTitleSuffix; } @@ -37,8 +37,8 @@ public function prepareForUsage(): SEOData image: $overrides->image ?? $this->image, url: $overrides->url ?? null, enableTitleSuffix: $enableTitleSuffix ?? true, - published_time: $overrides->published_time ?? ( $this->model?->created_at ?? null ), - modified_time: $overrides->modified_time ?? ( $this->model?->updated_at ?? null ), + published_time: $overrides->published_time ?? ($this->model?->created_at ?? null), + modified_time: $overrides->modified_time ?? ($this->model?->updated_at ?? null), articleBody: $overrides->articleBody ?? null, section: $overrides->section ?? null, tags: $overrides->tags ?? null, @@ -50,4 +50,4 @@ public function prepareForUsage(): SEOData openGraphTitle: $overrides->openGraphTitle ?? null, ); } -} \ No newline at end of file +} diff --git a/src/SEOManager.php b/src/SEOManager.php index c09d8b0..a539151 100644 --- a/src/SEOManager.php +++ b/src/SEOManager.php @@ -33,4 +33,4 @@ public function getSEODataTransformers(): array { return $this->SEODataTransformers; } -} \ No newline at end of file +} diff --git a/src/Schema/ArticleSchema.php b/src/Schema/ArticleSchema.php index ab3c41e..a7e79be 100644 --- a/src/Schema/ArticleSchema.php +++ b/src/Schema/ArticleSchema.php @@ -28,7 +28,7 @@ class ArticleSchema extends Schema public function addAuthor(string $authorName): static { - if ( empty($this->authors) ) { + if (empty($this->authors)) { $this->authors = [ '@type' => 'Person', 'name' => $authorName, @@ -62,12 +62,12 @@ public function initializeMarkup(SEOData $SEOData, array $markupBuilders): void ]; foreach ($properties as $markupProperty => $SEODataProperty) { - if ( $SEOData->{$SEODataProperty} ) { + if ($SEOData->{$SEODataProperty}) { $this->{$markupProperty} = $SEOData->{$SEODataProperty}; } } - if ( $SEOData->author ) { + if ($SEOData->author) { $this->authors = [ '@type' => 'Person', 'name' => $SEOData->author, @@ -85,9 +85,9 @@ public function generateInner(): string '@id' => $this->url, ], ]) - ->when($this->datePublished, fn (Collection $collection): Collection => $collection->put('datePublished', $this->datePublished->toIso8601String())) + ->when($this->datePublished, fn (Collection $collection): Collection => $collection->put('datePublished', $this->datePublished->toIso8601String())) ->when($this->dateModified, fn (Collection $collection): Collection => $collection->put('dateModified', $this->dateModified->toIso8601String())) - ->put('headline', $this->headline) + ->put('headline', $this->headline) ->when($this->authors, fn (Collection $collection): Collection => $collection->put('author', $this->authors)) ->when($this->description, fn (Collection $collection): Collection => $collection->put('description', $this->description)) ->when($this->image, fn (Collection $collection): Collection => $collection->put('image', $this->image)) diff --git a/src/Schema/BreadcrumbListSchema.php b/src/Schema/BreadcrumbListSchema.php index 5b74082..4cbb442 100644 --- a/src/Schema/BreadcrumbListSchema.php +++ b/src/Schema/BreadcrumbListSchema.php @@ -54,4 +54,4 @@ public function prependBreadcrumbs(array $breadcrumbs): static return $this; } -} \ No newline at end of file +} diff --git a/src/Schema/Schema.php b/src/Schema/Schema.php index a86d3a3..2d4294b 100644 --- a/src/Schema/Schema.php +++ b/src/Schema/Schema.php @@ -43,4 +43,4 @@ public function markup(Closure $transformer): static return $this; } -} \ No newline at end of file +} diff --git a/src/SchemaCollection.php b/src/SchemaCollection.php index dbde023..093af4d 100644 --- a/src/SchemaCollection.php +++ b/src/SchemaCollection.php @@ -5,7 +5,6 @@ use Closure; use Illuminate\Support\Collection; use RalphJSmit\Laravel\SEO\Schema\ArticleSchema; -use RalphJSmit\Laravel\SEO\Schema\BreadcrumbList; use RalphJSmit\Laravel\SEO\Schema\BreadcrumbListSchema; use RalphJSmit\Laravel\SEO\Schema\Schema; @@ -18,14 +17,14 @@ class SchemaCollection extends Collection public array $markup = []; - public function addArticle(Closure $builder = null): static + public function addArticle(?Closure $builder = null): static { $this->markup[$this->dictionary['article']][] = $builder ?: fn (Schema $schema): Schema => $schema; return $this; } - public function addBreadcrumbs(Closure $builder = null): static + public function addBreadcrumbs(?Closure $builder = null): static { $this->markup[$this->dictionary['breadcrumbs']][] = $builder ?: fn (Schema $schema): Schema => $schema; @@ -36,4 +35,4 @@ public static function initialize(): static { return new static(); } -} \ No newline at end of file +} diff --git a/src/Support/HasSEO.php b/src/Support/HasSEO.php index 72eab47..5215f48 100644 --- a/src/Support/HasSEO.php +++ b/src/Support/HasSEO.php @@ -22,4 +22,4 @@ public function seo(): MorphOne { return $this->morphOne(config('seo.model'), 'model')->withDefault(); } -} \ No newline at end of file +} diff --git a/src/Support/ImageMeta.php b/src/Support/ImageMeta.php index 720e4d4..5c14a9c 100644 --- a/src/Support/ImageMeta.php +++ b/src/Support/ImageMeta.php @@ -14,7 +14,7 @@ public function __construct(string $path) { $publicPath = public_path($path); - if ( ! is_file($publicPath) ) { + if (! is_file($publicPath)) { report(new Exception("Path {$publicPath} is not a file.")); return; diff --git a/src/Support/LinkTag.php b/src/Support/LinkTag.php index 9e09a9d..2523a03 100644 --- a/src/Support/LinkTag.php +++ b/src/Support/LinkTag.php @@ -9,5 +9,6 @@ class LinkTag extends Tag public function __construct( public string $rel, public string $href, - ) {} -} \ No newline at end of file + ) { + } +} diff --git a/src/Support/MetaContentTag.php b/src/Support/MetaContentTag.php index 530c310..86f2164 100644 --- a/src/Support/MetaContentTag.php +++ b/src/Support/MetaContentTag.php @@ -9,5 +9,6 @@ class MetaContentTag extends Tag public function __construct( public string $property, public string $content, - ) {} -} \ No newline at end of file + ) { + } +} diff --git a/src/Support/MetaTag.php b/src/Support/MetaTag.php index 119c387..e895727 100644 --- a/src/Support/MetaTag.php +++ b/src/Support/MetaTag.php @@ -9,5 +9,6 @@ class MetaTag extends Tag public function __construct( public string $name, public string $content, - ) {} -} \ No newline at end of file + ) { + } +} diff --git a/src/Support/OpenGraphTag.php b/src/Support/OpenGraphTag.php index 0f63e81..20acb61 100644 --- a/src/Support/OpenGraphTag.php +++ b/src/Support/OpenGraphTag.php @@ -14,7 +14,7 @@ public function __construct( ) { $this->attributesPipeline[] = function (Collection $collection) { return $collection->mapWithKeys(function ($value, $key) { - if ( $key === 'property' ) { + if ($key === 'property') { $value = 'og:' . $value; } @@ -22,4 +22,4 @@ public function __construct( }); }; } -} \ No newline at end of file +} diff --git a/src/Support/RenderableCollection.php b/src/Support/RenderableCollection.php index ca96da1..19010f3 100644 --- a/src/Support/RenderableCollection.php +++ b/src/Support/RenderableCollection.php @@ -12,7 +12,7 @@ public function render(): string return $this->reduce(function (string $carry, Renderable $item): string { return $carry .= Str::of( $item->render() - )->trim().PHP_EOL;; + )->trim() . PHP_EOL; }, ''); } -} \ No newline at end of file +} diff --git a/src/Support/SEOData.php b/src/Support/SEOData.php index 5d0e7c2..20b941f 100644 --- a/src/Support/SEOData.php +++ b/src/Support/SEOData.php @@ -3,7 +3,6 @@ namespace RalphJSmit\Laravel\SEO\Support; use Carbon\CarbonInterface; -use Illuminate\Support\Str; use RalphJSmit\Helpers\Laravel\Pipe\Pipeable; use RalphJSmit\Laravel\SEO\SchemaCollection; @@ -34,14 +33,14 @@ public function __construct( public ?string $canonical_url = null, public ?string $openGraphTitle = null, ) { - if ( $this->locale === null ) { + if ($this->locale === null) { $this->locale = app()->getLocale(); } } public function imageMeta(): ?ImageMeta { - if ( $this->image ) { + if ($this->image) { return $this->imageMeta ??= new ImageMeta($this->image); } @@ -54,4 +53,4 @@ public function markAsNoindex(): static return $this; } -} \ No newline at end of file +} diff --git a/src/Support/SchemaTagCollection.php b/src/Support/SchemaTagCollection.php index c390e4b..df52c01 100644 --- a/src/Support/SchemaTagCollection.php +++ b/src/Support/SchemaTagCollection.php @@ -10,11 +10,11 @@ class SchemaTagCollection extends Collection implements Renderable { use RenderableCollection; - public static function initialize(SEOData $SEOData, SchemaCollection $schema = null): ?static + public static function initialize(SEOData $SEOData, ?SchemaCollection $schema = null): ?static { $collection = new static(); - if ( ! $schema ) { + if (! $schema) { return null; } @@ -24,4 +24,4 @@ public static function initialize(SEOData $SEOData, SchemaCollection $schema = n return $collection; } -} \ No newline at end of file +} diff --git a/src/Support/SitemapTag.php b/src/Support/SitemapTag.php index dd974ce..c839532 100644 --- a/src/Support/SitemapTag.php +++ b/src/Support/SitemapTag.php @@ -12,5 +12,6 @@ class SitemapTag extends LinkTag public function __construct( public string $href - ) {} -} \ No newline at end of file + ) { + } +} diff --git a/src/Support/Tag.php b/src/Support/Tag.php index 9d95041..704ea2e 100644 --- a/src/Support/Tag.php +++ b/src/Support/Tag.php @@ -20,7 +20,7 @@ abstract class Tag implements Renderable public function render(): View { - return view("seo::tags.tag", [ + return view('seo::tags.tag', [ 'tag' => $this->tag, 'attributes' => $this->collectAttributes(), 'inner' => $this->inner ?? null, @@ -38,4 +38,4 @@ public function collectAttributes(): Collection }) ->pipeThrough($this->attributesPipeline); } -} \ No newline at end of file +} diff --git a/src/Support/TwitterCardTag.php b/src/Support/TwitterCardTag.php index 1fc406a..d3051cf 100644 --- a/src/Support/TwitterCardTag.php +++ b/src/Support/TwitterCardTag.php @@ -14,7 +14,7 @@ public function __construct( ) { $this->attributesPipeline[] = function (Collection $collection) { return $collection->mapWithKeys(function ($value, $key) { - if ( $key === 'name' ) { + if ($key === 'name') { $value = 'twitter:' . $value; } @@ -22,4 +22,4 @@ public function __construct( }); }; } -} \ No newline at end of file +} diff --git a/src/TagCollection.php b/src/TagCollection.php index 2f29f45..d595610 100644 --- a/src/TagCollection.php +++ b/src/TagCollection.php @@ -19,7 +19,7 @@ class TagCollection extends Collection { - public static function initialize(SEOData $SEOData = null): static + public static function initialize(?SEOData $SEOData = null): static { $collection = new static(); @@ -43,4 +43,4 @@ public static function initialize(SEOData $SEOData = null): static return $collection; } -} \ No newline at end of file +} diff --git a/src/TagManager.php b/src/TagManager.php index 4fc7349..b6edd46 100644 --- a/src/TagManager.php +++ b/src/TagManager.php @@ -23,7 +23,7 @@ public function __construct() ); } - public function fillSEOData(SEOData $SEOData = null): SEOData + public function fillSEOData(?SEOData $SEOData = null): SEOData { $SEOData ??= new SEOData(); @@ -38,12 +38,12 @@ public function fillSEOData(SEOData $SEOData = null): SEOData ]; foreach ($defaults as $property => $defaultValue) { - if ( $SEOData->{$property} === null ) { + if ($SEOData->{$property} === null) { $SEOData->{$property} = $defaultValue; } } - if ( $SEOData->enableTitleSuffix ) { + if ($SEOData->enableTitleSuffix) { $SEOData->title .= config('seo.title.suffix'); if ($SEOData->openGraphTitle) { @@ -51,21 +51,21 @@ public function fillSEOData(SEOData $SEOData = null): SEOData } } - if ( $SEOData->image && ! filter_var($SEOData->image, FILTER_VALIDATE_URL) ) { + if ($SEOData->image && ! filter_var($SEOData->image, FILTER_VALIDATE_URL)) { $SEOData->imageMeta(); $SEOData->image = secure_url($SEOData->image); } - if ( $SEOData->favicon && ! filter_var($SEOData->favicon, FILTER_VALIDATE_URL) ) { + if ($SEOData->favicon && ! filter_var($SEOData->favicon, FILTER_VALIDATE_URL)) { $SEOData->favicon = secure_url($SEOData->favicon); } - if ( ! $SEOData->url ) { + if (! $SEOData->url) { $SEOData->url = url()->current(); } - if ( $SEOData->url === url('/') && ( $homepageTitle = config('seo.title.homepage_title') ) ) { + if ($SEOData->url === url('/') && ($homepageTitle = config('seo.title.homepage_title'))) { $SEOData->title = $homepageTitle; } @@ -74,12 +74,12 @@ public function fillSEOData(SEOData $SEOData = null): SEOData ); } - public function for(Model|SEOData $source): static + public function for(Model | SEOData $source): static { - if ( $source instanceof Model ) { + if ($source instanceof Model) { $this->model = $source; unset($this->SEOData); - } elseif ( $source instanceof SEOData ) { + } elseif ($source instanceof SEOData) { unset($this->model); $this->SEOData = $source; } @@ -111,7 +111,7 @@ public function render(): string return $this->tags ->pipeThrough(SEOManager::getTagTransformers()) ->reduce(function (string $carry, Renderable $item) { - return $carry .= Str::of($item->render())->trim().PHP_EOL; + return $carry .= Str::of($item->render())->trim() . PHP_EOL; }, ''); } @@ -119,4 +119,4 @@ public function __toString(): string { return $this->render(); } -} \ No newline at end of file +} diff --git a/src/Tags/AuthorTag.php b/src/Tags/AuthorTag.php index bd4f968..666f823 100644 --- a/src/Tags/AuthorTag.php +++ b/src/Tags/AuthorTag.php @@ -7,11 +7,11 @@ class AuthorTag extends MetaTag { - public static function initialize(?SEOData $SEOData): MetaTag|null + public static function initialize(?SEOData $SEOData): ?MetaTag { $author = $SEOData?->author; - if ( ! $author ) { + if (! $author) { return null; } @@ -20,4 +20,4 @@ public static function initialize(?SEOData $SEOData): MetaTag|null content: trim($author) ); } -} \ No newline at end of file +} diff --git a/src/Tags/CanonicalTag.php b/src/Tags/CanonicalTag.php index 82c00bb..436796d 100644 --- a/src/Tags/CanonicalTag.php +++ b/src/Tags/CanonicalTag.php @@ -12,14 +12,14 @@ class CanonicalTag extends Collection implements Renderable { use RenderableCollection; - public static function initialize(SEOData $SEOData = null): static + public static function initialize(?SEOData $SEOData = null): static { $collection = new static(); - if ( config('seo.canonical_link') ) { + if (config('seo.canonical_link')) { $collection->push(new LinkTag('canonical', $SEOData->canonical_url ?? $SEOData->url)); } return $collection; } -} \ No newline at end of file +} diff --git a/src/Tags/DescriptionTag.php b/src/Tags/DescriptionTag.php index a174612..53b6e62 100644 --- a/src/Tags/DescriptionTag.php +++ b/src/Tags/DescriptionTag.php @@ -7,11 +7,11 @@ class DescriptionTag extends MetaTag { - public static function initialize(?SEOData $SEOData): MetaTag|null + public static function initialize(?SEOData $SEOData): ?MetaTag { $description = $SEOData?->description; - if ( ! $description ) { + if (! $description) { return null; } @@ -20,4 +20,4 @@ public static function initialize(?SEOData $SEOData): MetaTag|null content: trim($description) ); } -} \ No newline at end of file +} diff --git a/src/Tags/FaviconTag.php b/src/Tags/FaviconTag.php index bf68765..cb9a98d 100644 --- a/src/Tags/FaviconTag.php +++ b/src/Tags/FaviconTag.php @@ -8,11 +8,11 @@ class FaviconTag extends LinkTag { - public static function initialize(?SEOData $SEOData): static|null + public static function initialize(?SEOData $SEOData): ?static { $favicon = $SEOData?->favicon; - if ( ! $favicon ) { + if (! $favicon) { return null; } @@ -27,4 +27,4 @@ public function collectAttributes(): Collection return parent::collectAttributes() ->sortKeys(); } -} \ No newline at end of file +} diff --git a/src/Tags/ImageTag.php b/src/Tags/ImageTag.php index 2d3c39b..554cded 100644 --- a/src/Tags/ImageTag.php +++ b/src/Tags/ImageTag.php @@ -7,11 +7,11 @@ class ImageTag extends MetaTag { - public static function initialize(?SEOData $SEOData): MetaTag|null + public static function initialize(?SEOData $SEOData): ?MetaTag { $image = $SEOData?->image; - if ( ! $image ) { + if (! $image) { return null; } @@ -20,4 +20,4 @@ public static function initialize(?SEOData $SEOData): MetaTag|null content: trim($image) ); } -} \ No newline at end of file +} diff --git a/src/Tags/OpenGraphTags.php b/src/Tags/OpenGraphTags.php index a2799a7..a172d72 100644 --- a/src/Tags/OpenGraphTags.php +++ b/src/Tags/OpenGraphTags.php @@ -17,24 +17,24 @@ public static function initialize(SEOData $SEOData): static { $collection = new static(); - if ( $SEOData->openGraphTitle ) { + if ($SEOData->openGraphTitle) { $collection->push(new OpenGraphTag('title', $SEOData->openGraphTitle)); - } else if ( $SEOData->title ) { + } elseif ($SEOData->title) { $collection->push(new OpenGraphTag('title', $SEOData->title)); } - if ( $SEOData->description ) { + if ($SEOData->description) { $collection->push(new OpenGraphTag('description', $SEOData->description)); } - if ( $SEOData->locale ) { + if ($SEOData->locale) { $collection->push(new OpenGraphTag('locale', $SEOData->locale)); } - if ( $SEOData->image ) { + if ($SEOData->image) { $collection->push(new OpenGraphTag('image', $SEOData->image)); - if ( $SEOData->imageMeta ) { + if ($SEOData->imageMeta) { $collection ->when($SEOData->imageMeta->width, fn (self $collection): self => $collection->push(new OpenGraphTag('image:width', $SEOData->imageMeta->width))) ->when($SEOData->imageMeta->height, fn (self $collection): self => $collection->push(new OpenGraphTag('image:height', $SEOData->imageMeta->height))); @@ -43,27 +43,27 @@ public static function initialize(SEOData $SEOData): static $collection->push(new OpenGraphTag('url', $SEOData->url)); - if ( $SEOData->site_name ) { + if ($SEOData->site_name) { $collection->push(new OpenGraphTag('site_name', $SEOData->site_name)); } - if ( $SEOData->type ) { + if ($SEOData->type) { $collection->push(new OpenGraphTag('type', $SEOData->type)); } - if ( $SEOData->published_time && $SEOData->type === 'article' ) { + if ($SEOData->published_time && $SEOData->type === 'article') { $collection->push(new MetaContentTag('article:published_time', $SEOData->published_time->toIso8601String())); } - if ( $SEOData->modified_time && $SEOData->type === 'article' ) { + if ($SEOData->modified_time && $SEOData->type === 'article') { $collection->push(new MetaContentTag('article:modified_time', $SEOData->modified_time->toIso8601String())); } - if ( $SEOData->section && $SEOData->type === 'article' ) { + if ($SEOData->section && $SEOData->type === 'article') { $collection->push(new MetaContentTag('article:section', $SEOData->section)); } - if ( $SEOData->tags && $SEOData->type === 'article' ) { + if ($SEOData->tags && $SEOData->type === 'article') { foreach ($SEOData->tags as $tag) { $collection->push(new MetaContentTag('article:tag', $tag)); } @@ -71,4 +71,4 @@ public static function initialize(SEOData $SEOData): static return $collection; } -} \ No newline at end of file +} diff --git a/src/Tags/RobotsTag.php b/src/Tags/RobotsTag.php index 999e654..67d35b5 100644 --- a/src/Tags/RobotsTag.php +++ b/src/Tags/RobotsTag.php @@ -12,13 +12,13 @@ class RobotsTag extends Collection implements Renderable { use RenderableCollection; - public static function initialize(SEOData $SEOData = null): static + public static function initialize(?SEOData $SEOData = null): static { $collection = new static(); $robotsContent = config('seo.robots.default'); - if ( ! config('seo.robots.force_default') ) { + if (! config('seo.robots.force_default')) { $robotsContent = $SEOData?->robots ?? $robotsContent; } @@ -26,4 +26,4 @@ public static function initialize(SEOData $SEOData = null): static return $collection; } -} \ No newline at end of file +} diff --git a/src/Tags/SitemapTag.php b/src/Tags/SitemapTag.php index c727068..bb56904 100644 --- a/src/Tags/SitemapTag.php +++ b/src/Tags/SitemapTag.php @@ -12,14 +12,14 @@ class SitemapTag extends Collection implements Renderable { use RenderableCollection; - public static function initialize(SEOData $SEOData = null): static + public static function initialize(?SEOData $SEOData = null): static { $collection = new static(); - if ( $sitemap = config('seo.sitemap') ) { + if ($sitemap = config('seo.sitemap')) { $collection->push(new SitemapTagSupport($sitemap)); } return $collection; } -} \ No newline at end of file +} diff --git a/src/Tags/TitleTag.php b/src/Tags/TitleTag.php index a5ef7be..13bff8e 100644 --- a/src/Tags/TitleTag.php +++ b/src/Tags/TitleTag.php @@ -11,13 +11,14 @@ class TitleTag extends Tag public function __construct( public string $inner, - ) {} + ) { + } - public static function initialize(?SEOData $SEOData): Tag|null + public static function initialize(?SEOData $SEOData): ?Tag { $title = $SEOData?->title; - if ( ! $title ) { + if (! $title) { return null; } @@ -25,4 +26,4 @@ public static function initialize(?SEOData $SEOData): Tag|null inner: trim($title), ); } -} \ No newline at end of file +} diff --git a/src/Tags/TwitterCard/Summary.php b/src/Tags/TwitterCard/Summary.php index 2d9c5fc..f8dd680 100644 --- a/src/Tags/TwitterCard/Summary.php +++ b/src/Tags/TwitterCard/Summary.php @@ -16,30 +16,30 @@ public static function initialize(SEOData $SEOData): static { $collection = new static(); - if ( $SEOData->imageMeta ) { - if ( $SEOData->imageMeta->width < 144 ) { + if ($SEOData->imageMeta) { + if ($SEOData->imageMeta->width < 144) { return $collection; } - if ( $SEOData->imageMeta->height < 144 ) { + if ($SEOData->imageMeta->height < 144) { return $collection; } - if ( $SEOData->imageMeta->width > 4096 ) { + if ($SEOData->imageMeta->width > 4096) { return $collection; } - if ( $SEOData->imageMeta->height > 4096 ) { + if ($SEOData->imageMeta->height > 4096) { return $collection; } } $collection->push(new TwitterCardTag('card', 'summary')); - if ( $SEOData->image ) { + if ($SEOData->image) { $collection->push(new TwitterCardTag('image', $SEOData->image)); - if ( $SEOData->imageMeta ) { + if ($SEOData->imageMeta) { $collection ->when($SEOData->imageMeta?->width, fn (self $collection): self => $collection->push(new TwitterCardTag('image:width', $SEOData->imageMeta->width))) ->when($SEOData->imageMeta?->height, fn (self $collection): self => $collection->push(new TwitterCardTag('image:height', $SEOData->imageMeta->height))); @@ -48,4 +48,4 @@ public static function initialize(SEOData $SEOData): static return $collection; } -} \ No newline at end of file +} diff --git a/src/Tags/TwitterCard/SummaryLargeImage.php b/src/Tags/TwitterCard/SummaryLargeImage.php index 42090f4..fba8032 100644 --- a/src/Tags/TwitterCard/SummaryLargeImage.php +++ b/src/Tags/TwitterCard/SummaryLargeImage.php @@ -16,30 +16,30 @@ public static function initialize(SEOData $SEOData): static { $collection = new static(); - if ( $SEOData->imageMeta ) { - if ( $SEOData->imageMeta->width < 300 ) { + if ($SEOData->imageMeta) { + if ($SEOData->imageMeta->width < 300) { return $collection; } - if ( $SEOData->imageMeta->height < 157 ) { + if ($SEOData->imageMeta->height < 157) { return $collection; } - if ( $SEOData->imageMeta->width > 4096 ) { + if ($SEOData->imageMeta->width > 4096) { return $collection; } - if ( $SEOData->imageMeta->height > 4096 ) { + if ($SEOData->imageMeta->height > 4096) { return $collection; } } $collection->push(new TwitterCardTag('card', 'summary_large_image')); - if ( $SEOData->image ) { + if ($SEOData->image) { $collection->push(new TwitterCardTag('image', $SEOData->image)); - if ( $SEOData->imageMeta ) { + if ($SEOData->imageMeta) { $collection ->when($SEOData->imageMeta?->width, fn (self $collection): self => $collection->push(new TwitterCardTag('image:width', $SEOData->imageMeta->width))) ->when($SEOData->imageMeta?->height, fn (self $collection): self => $collection->push(new TwitterCardTag('image:height', $SEOData->imageMeta->height))); @@ -48,4 +48,4 @@ public static function initialize(SEOData $SEOData): static return $collection; } -} \ No newline at end of file +} diff --git a/src/Tags/TwitterCardTags.php b/src/Tags/TwitterCardTags.php index 524a8e6..86aa910 100644 --- a/src/Tags/TwitterCardTags.php +++ b/src/Tags/TwitterCardTags.php @@ -19,32 +19,32 @@ public static function initialize(SEOData $SEOData): ?static $collection = new static(); // No generic image that spans multiple pages - if ( $SEOData->image && $SEOData->image !== secure_url(config('seo.image.fallback')) ) { - if ( $SEOData->imageMeta?->width - $SEOData->imageMeta?->height - 20 < 0 ) { + if ($SEOData->image && $SEOData->image !== secure_url(config('seo.image.fallback'))) { + if ($SEOData->imageMeta?->width - $SEOData->imageMeta?->height - 20 < 0) { $collection->push(Summary::initialize($SEOData)); } - if ( $SEOData->imageMeta?->width - 2 * $SEOData->imageMeta?->height - 20 < 0 ) { + if ($SEOData->imageMeta?->width - 2 * $SEOData->imageMeta?->height - 20 < 0) { $collection->push(SummaryLargeImage::initialize($SEOData)); } } else { $collection->push(new TwitterCardTag('card', 'summary')); } - if ( $SEOData->openGraphTitle ) { + if ($SEOData->openGraphTitle) { $collection->push(new TwitterCardTag('title', $SEOData->openGraphTitle)); - } else if ( $SEOData->title ) { + } elseif ($SEOData->title) { $collection->push(new TwitterCardTag('title', $SEOData->title)); } - if ( $SEOData->description ) { + if ($SEOData->description) { $collection->push(new TwitterCardTag('description', $SEOData->description)); } - if ( $SEOData->twitter_username && $SEOData->twitter_username !== '@' ) { + if ($SEOData->twitter_username && $SEOData->twitter_username !== '@') { $collection->push(new TwitterCardTag('site', $SEOData->twitter_username)); } return $collection; } -} \ No newline at end of file +} diff --git a/src/helpers.php b/src/helpers.php index 2ee4745..ccdc3dc 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -4,15 +4,15 @@ use RalphJSmit\Laravel\SEO\Support\SEOData; use RalphJSmit\Laravel\SEO\TagManager; -if ( ! function_exists('seo') ) { - function seo(Model|SEOData $source = null): TagManager +if (! function_exists('seo')) { + function seo(Model | SEOData | null $source = null): TagManager { $tagManager = app(TagManager::class); - if ( $source ) { + if ($source) { $tagManager->for($source); } return $tagManager; } -} \ No newline at end of file +} diff --git a/tests/Feature/JSON-LD/ArticleTest.php b/tests/Feature/JSON-LD/ArticleTest.php index 4eaef75..9b2d9f8 100644 --- a/tests/Feature/JSON-LD/ArticleTest.php +++ b/tests/Feature/JSON-LD/ArticleTest.php @@ -7,7 +7,7 @@ use function Pest\Laravel\get; beforeEach(function () { - if ( ! file_exists($dir = public_path('images')) ) { + if (! file_exists($dir = public_path('images'))) { mkdir($dir, 0777, true); } @@ -64,4 +64,3 @@ false ); }); - diff --git a/tests/Feature/JSON-LD/BreadcrumbListTest.php b/tests/Feature/JSON-LD/BreadcrumbListTest.php index d9ce338..4f7c211 100644 --- a/tests/Feature/JSON-LD/BreadcrumbListTest.php +++ b/tests/Feature/JSON-LD/BreadcrumbListTest.php @@ -1,6 +1,5 @@ assertSee('', false); -}); \ No newline at end of file +}); diff --git a/tests/Feature/Tags/CanonicalTagTest.php b/tests/Feature/Tags/CanonicalTagTest.php index 87ae901..8d2856a 100644 --- a/tests/Feature/Tags/CanonicalTagTest.php +++ b/tests/Feature/Tags/CanonicalTagTest.php @@ -72,5 +72,5 @@ get(route('seo.test-page', ['page' => $page])) ->assertOk(); }) - // Skip tests on Laravel 9, so we don't need to install Doctrine for this test only. - ->skip(version_compare(Illuminate\Foundation\Application::VERSION, '10', 'lt')); \ No newline at end of file + // Skip tests on Laravel 9, so we don't need to install Doctrine for this test only. + ->skip(version_compare(Illuminate\Foundation\Application::VERSION, '10', 'lt')); diff --git a/tests/Feature/Tags/FaviconTagTest.php b/tests/Feature/Tags/FaviconTagTest.php index 2cec5ae..68365d8 100644 --- a/tests/Feature/Tags/FaviconTagTest.php +++ b/tests/Feature/Tags/FaviconTagTest.php @@ -18,4 +18,4 @@ get(route('seo.test-plain')) ->assertSee('', false); -}); \ No newline at end of file +}); diff --git a/tests/Feature/Tags/ImageTagTest.php b/tests/Feature/Tags/ImageTagTest.php index 3d5748e..f0867b0 100644 --- a/tests/Feature/Tags/ImageTagTest.php +++ b/tests/Feature/Tags/ImageTagTest.php @@ -5,11 +5,11 @@ use function Pest\Laravel\get; beforeEach(function () { - if ( ! file_exists($dir = public_path('test')) ) { + if (! file_exists($dir = public_path('test'))) { mkdir($dir, 0777, true); } - if ( ! file_exists($dir = storage_path('test')) ) { + if (! file_exists($dir = storage_path('test'))) { mkdir($dir, 0777, true); } @@ -55,4 +55,3 @@ get(route('seo.test-page', ['page' => $page])) ->assertSee('', false); }); - diff --git a/tests/Feature/Tags/OpenGraphTagsTest.php b/tests/Feature/Tags/OpenGraphTagsTest.php index 974c5b5..06291d0 100644 --- a/tests/Feature/Tags/OpenGraphTagsTest.php +++ b/tests/Feature/Tags/OpenGraphTagsTest.php @@ -6,7 +6,7 @@ use function Spatie\PestPluginTestTime\testTime; beforeEach(function () { - if ( ! file_exists($dir = public_path('images/foo')) ) { + if (! file_exists($dir = public_path('images/foo'))) { mkdir($dir, 0777, true); } @@ -123,7 +123,7 @@ ->assertSee('', false); }); -it('uses openGraphTitle over title', function() { +it('uses openGraphTitle over title', function () { config()->set('seo.title.suffix', ' | Laravel SEO'); $page = Page::create(); diff --git a/tests/Feature/Tags/RobotsTagTest.php b/tests/Feature/Tags/RobotsTagTest.php index 3920cb6..6ecdeb2 100644 --- a/tests/Feature/Tags/RobotsTagTest.php +++ b/tests/Feature/Tags/RobotsTagTest.php @@ -4,7 +4,6 @@ use RalphJSmit\Laravel\SEO\Tests\Fixtures\Page; use function Pest\Laravel\get; -use function Pest\Laravel\post; it('can output the robots tag "default" value', function () { config()->set('seo.robots.default', 'max-snippet:-1'); @@ -66,4 +65,4 @@ get(route('seo.test-page', ['page' => $page])) ->assertSee('', false); -}); \ No newline at end of file +}); diff --git a/tests/Feature/Tags/SitemapTagTest.php b/tests/Feature/Tags/SitemapTagTest.php index 888124d..369ea1e 100644 --- a/tests/Feature/Tags/SitemapTagTest.php +++ b/tests/Feature/Tags/SitemapTagTest.php @@ -1,7 +1,5 @@ $page])) ->assertSee('
Test
', + ]) . '' ); }); @@ -81,4 +81,4 @@ 'alternativeHeadline' => 'My alternative headline', ]) . '' ); -}); \ No newline at end of file +}); diff --git a/tests/Unit/Schema/BreadcrumbListSchemaTest.php b/tests/Unit/Schema/BreadcrumbListSchemaTest.php index a9f597e..599dd68 100644 --- a/tests/Unit/Schema/BreadcrumbListSchemaTest.php +++ b/tests/Unit/Schema/BreadcrumbListSchemaTest.php @@ -54,4 +54,4 @@ ], ]) . '' ); -}); \ No newline at end of file +}); diff --git a/tests/Unit/Support/HasSEOTest.php b/tests/Unit/Support/HasSEOTest.php index be002cf..8aa0835 100644 --- a/tests/Unit/Support/HasSEOTest.php +++ b/tests/Unit/Support/HasSEOTest.php @@ -7,4 +7,4 @@ expect($page->seo) ->not->toBeNull(); -}); \ No newline at end of file +}); diff --git a/tests/Unit/Support/SEODataTest.php b/tests/Unit/Support/SEODataTest.php index ab05e1f..1c683bd 100644 --- a/tests/Unit/Support/SEODataTest.php +++ b/tests/Unit/Support/SEODataTest.php @@ -41,4 +41,4 @@ $page->touch(); assertDatabaseCount(SEO::class, 0); -}); \ No newline at end of file +});