Skip to content

Commit

Permalink
Run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkleemans committed Aug 31, 2022
1 parent 958808d commit 8537632
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
13 changes: 6 additions & 7 deletions src/AttributeEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Kleemans\Tests\Fake\OrderStatus;

trait AttributeEvents
{
Expand Down Expand Up @@ -33,21 +32,21 @@ private function fireAttributeEvents(): void

// Accessor
if ($this->hasAccessor($attribute)) {
if (! $this->isDirtyAccessor($attribute)) {
if (!$this->isDirtyAccessor($attribute)) {
continue; // Not changed
}
} // JSON attribute
elseif (Str::contains($attribute, '->')) {
[$attribute, $path] = explode('->', $attribute, 2);
$path = str_replace('->', '.', $path);

if (! $this->isDirtyNested($attribute, $path)) {
if (!$this->isDirtyNested($attribute, $path)) {
continue; // Not changed
}

$value = Arr::get($this->getAttribute($attribute), $path);
} // Regular attribute
elseif (! $this->isDirty($attribute)) {
elseif (!$this->isDirty($attribute)) {
continue; // Not changed
}

Expand All @@ -70,7 +69,7 @@ private function syncOriginalAccessors(): void
foreach ($this->getAttributeEvents() as $change => $event) {
[$attribute] = explode(':', $change);

if (! $this->hasAccessor($attribute)) {
if (!$this->hasAccessor($attribute)) {
continue; // Attribute does not have accessor
}

Expand All @@ -85,7 +84,7 @@ private function syncOriginalAccessors(): void

public function isDirtyAccessor(string $attribute): bool
{
if (! isset($this->originalAccessors[$attribute])) {
if (!isset($this->originalAccessors[$attribute])) {
return false; // Attribute does not have a original value saved
}

Expand Down Expand Up @@ -113,7 +112,7 @@ public function isDirtyNested(string $attribute, string $path): bool
private function getAttributeEvents(): iterable
{
foreach ($this->dispatchesEvents as $change => $event) {
if (! Str::contains($change, ':')) {
if (!Str::contains($change, ':')) {
continue; // Not an attribute event
}

Expand Down
1 change: 0 additions & 1 deletion tests/Fake/EnumOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Kleemans\Tests\Fake;

use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Kleemans\AttributeEvents;

Expand Down
1 change: 0 additions & 1 deletion tests/Fake/Events/EnumOrderShipped.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Kleemans\Tests\Fake\Events;

use Kleemans\Tests\Fake\EnumOrder;
use Kleemans\Tests\Fake\Order;

class EnumOrderShipped
{
Expand Down
20 changes: 10 additions & 10 deletions tests/Fake/OrderStatus.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Kleemans\Tests\Fake;

enum OrderStatus: int
{
case PROCESSING = 1;
case SHIPPED = 2;
case CANCELLED = 3;
}
<?php

namespace Kleemans\Tests\Fake;

enum OrderStatus: int
{
case PROCESSING = 1;
case SHIPPED = 2;
case CANCELLED = 3;
}

0 comments on commit 8537632

Please sign in to comment.