Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Gummibeer authored and github-actions[bot] committed Nov 10, 2022
1 parent e2cc899 commit b660c42
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/Actions/ResolveForPropertyValueAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
4 changes: 1 addition & 3 deletions tests/AbleStoreNonBackedEnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -36,4 +35,3 @@
->and($latestActivity->properties['role'])->toEqual('User');
})
->skip(version_compare(PHP_VERSION, '8.1', '<'), "PHP < 8.1 doesn't support enum");

0 comments on commit b660c42

Please sign in to comment.