Skip to content

Commit

Permalink
style: apply Pint
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphjsmit committed Mar 14, 2024
1 parent adfade5 commit 7671c6d
Show file tree
Hide file tree
Showing 59 changed files with 194 additions and 179 deletions.
23 changes: 23 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
2 changes: 1 addition & 1 deletion src/Facades/SEOManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ protected static function getFacadeAccessor()
{
return \RalphJSmit\Laravel\SEO\SEOManager::class;
}
}
}
12 changes: 6 additions & 6 deletions src/Models/SEO.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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,
Expand All @@ -50,4 +50,4 @@ public function prepareForUsage(): SEOData
openGraphTitle: $overrides->openGraphTitle ?? null,
);
}
}
}
2 changes: 1 addition & 1 deletion src/SEOManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ public function getSEODataTransformers(): array
{
return $this->SEODataTransformers;
}
}
}
10 changes: 5 additions & 5 deletions src/Schema/ArticleSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/BreadcrumbListSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ public function prependBreadcrumbs(array $breadcrumbs): static

return $this;
}
}
}
2 changes: 1 addition & 1 deletion src/Schema/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ public function markup(Closure $transformer): static

return $this;
}
}
}
7 changes: 3 additions & 4 deletions src/SchemaCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -36,4 +35,4 @@ public static function initialize(): static
{
return new static();
}
}
}
2 changes: 1 addition & 1 deletion src/Support/HasSEO.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public function seo(): MorphOne
{
return $this->morphOne(config('seo.model'), 'model')->withDefault();
}
}
}
2 changes: 1 addition & 1 deletion src/Support/ImageMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/Support/LinkTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ class LinkTag extends Tag
public function __construct(
public string $rel,
public string $href,
) {}
}
) {
}
}
5 changes: 3 additions & 2 deletions src/Support/MetaContentTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ class MetaContentTag extends Tag
public function __construct(
public string $property,
public string $content,
) {}
}
) {
}
}
5 changes: 3 additions & 2 deletions src/Support/MetaTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ class MetaTag extends Tag
public function __construct(
public string $name,
public string $content,
) {}
}
) {
}
}
4 changes: 2 additions & 2 deletions src/Support/OpenGraphTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public function __construct(
) {
$this->attributesPipeline[] = function (Collection $collection) {
return $collection->mapWithKeys(function ($value, $key) {
if ( $key === 'property' ) {
if ($key === 'property') {
$value = 'og:' . $value;
}

return [$key => $value];
});
};
}
}
}
4 changes: 2 additions & 2 deletions src/Support/RenderableCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}, '');
}
}
}
7 changes: 3 additions & 4 deletions src/Support/SEOData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

Expand All @@ -54,4 +53,4 @@ public function markAsNoindex(): static

return $this;
}
}
}
6 changes: 3 additions & 3 deletions src/Support/SchemaTagCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -24,4 +24,4 @@ public static function initialize(SEOData $SEOData, SchemaCollection $schema = n

return $collection;
}
}
}
5 changes: 3 additions & 2 deletions src/Support/SitemapTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ class SitemapTag extends LinkTag

public function __construct(
public string $href
) {}
}
) {
}
}
4 changes: 2 additions & 2 deletions src/Support/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -38,4 +38,4 @@ public function collectAttributes(): Collection
})
->pipeThrough($this->attributesPipeline);
}
}
}
4 changes: 2 additions & 2 deletions src/Support/TwitterCardTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public function __construct(
) {
$this->attributesPipeline[] = function (Collection $collection) {
return $collection->mapWithKeys(function ($value, $key) {
if ( $key === 'name' ) {
if ($key === 'name') {
$value = 'twitter:' . $value;
}

return [$key => $value];
});
};
}
}
}
4 changes: 2 additions & 2 deletions src/TagCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -43,4 +43,4 @@ public static function initialize(SEOData $SEOData = null): static

return $collection;
}
}
}
Loading

0 comments on commit 7671c6d

Please sign in to comment.