Skeleton is ready
This commit is contained in:
27
app/Kernel/Object/Enum.php
Normal file
27
app/Kernel/Object/Enum.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Kernel\Object;
|
||||
|
||||
use BackedEnum;
|
||||
|
||||
class Enum
|
||||
{
|
||||
/**
|
||||
* Extract values from an array of BackedEnum instances.
|
||||
*
|
||||
* @param array<int,BackedEnum> $enums
|
||||
*
|
||||
* @return array<int,int|string|float>
|
||||
*/
|
||||
public static function values(array $enums): array
|
||||
{
|
||||
return array_map(fn (BackedEnum $enum) => static::value($enum), $enums);
|
||||
}
|
||||
|
||||
public static function value(BackedEnum $enum): int|string|float
|
||||
{
|
||||
return $enum->value;
|
||||
}
|
||||
}
|
||||
17
app/Kernel/Object/HasHiddenAttributes.php
Normal file
17
app/Kernel/Object/HasHiddenAttributes.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Kernel\Object;
|
||||
|
||||
trait HasHiddenAttributes
|
||||
{
|
||||
public function isHidden(string $key): bool
|
||||
{
|
||||
if (property_exists($this, 'hidden') && is_array($this->hidden)) {
|
||||
return in_array($key, $this->hidden, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
10
app/Kernel/Object/HasPermissions.php
Normal file
10
app/Kernel/Object/HasPermissions.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Kernel\Object;
|
||||
|
||||
interface HasPermissions
|
||||
{
|
||||
public function permissions(): array;
|
||||
}
|
||||
10
app/Kernel/Object/HasRoles.php
Normal file
10
app/Kernel/Object/HasRoles.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Kernel\Object;
|
||||
|
||||
interface HasRoles
|
||||
{
|
||||
public function roles(): array;
|
||||
}
|
||||
7
app/Kernel/Object/HasRolesWithPermissions.php
Normal file
7
app/Kernel/Object/HasRolesWithPermissions.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Kernel\Object;
|
||||
|
||||
interface HasRolesWithPermissions extends HasRoles, HasPermissions {}
|
||||
10
app/Kernel/Object/HasUuidAsIdentifier.php
Normal file
10
app/Kernel/Object/HasUuidAsIdentifier.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Kernel\Object;
|
||||
|
||||
interface HasUuidAsIdentifier
|
||||
{
|
||||
public function id(): string;
|
||||
}
|
||||
Reference in New Issue
Block a user