From b660c42977652ab3af3cf7655c5c63092a1b440d Mon Sep 17 00:00:00 2001 From: Gummibeer Date: Thu, 10 Nov 2022 10:33:06 +0000 Subject: [PATCH] Fix styling --- src/Actions/ResolveForPropertyValueAction.php | 11 ++++++----- tests/AbleStoreNonBackedEnumTest.php | 4 +--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Actions/ResolveForPropertyValueAction.php b/src/Actions/ResolveForPropertyValueAction.php index 2d742752..c4cc91c9 100644 --- a/src/Actions/ResolveForPropertyValueAction.php +++ b/src/Actions/ResolveForPropertyValueAction.php @@ -6,17 +6,18 @@ class ResolveForPropertyValueAction { /** * Action that resolve property value of log - * that cannot be handled by PHP as default + * that cannot be handled by PHP as default. * * @param mixed $value + * * @return mixed */ public static function execute(mixed $value): mixed { - $instance = new static; + $instance = new static(); /** - * Give a fallback value if value not a backed enum + * Give a fallback value if value not a backed enum. */ if ($instance->isValueAnEnum($value)) { return $value->value ?? $value->name; @@ -27,11 +28,11 @@ public static function execute(mixed $value): mixed protected function isValueAnEnum($value): bool { - if (! function_exists('enum_exists')){ + if (! function_exists('enum_exists')) { return false; } - $enumNamespace = is_object($value) ? get_class($value): $value; + $enumNamespace = is_object($value) ? get_class($value) : $value; return ! is_array($value) && enum_exists($enumNamespace); } diff --git a/tests/AbleStoreNonBackedEnumTest.php b/tests/AbleStoreNonBackedEnumTest.php index 0366d11a..034b4211 100644 --- a/tests/AbleStoreNonBackedEnumTest.php +++ b/tests/AbleStoreNonBackedEnumTest.php @@ -2,12 +2,11 @@ namespace Spatie\Activitylog\Test; -use Illuminate\Support\Str; use Spatie\Activitylog\Test\Enum\NonBackedEnum; use Spatie\Activitylog\Test\Models\Activity; use Spatie\Activitylog\Test\Models\User; -afterEach(fn() => Activity::query()->latest()->first()->delete()); +afterEach(fn () => Activity::query()->latest()->first()->delete()); it('can store non-backed enum only a property', function () { $description = 'ROLE LOG'; @@ -36,4 +35,3 @@ ->and($latestActivity->properties['role'])->toEqual('User'); }) ->skip(version_compare(PHP_VERSION, '8.1', '<'), "PHP < 8.1 doesn't support enum"); -