mirror of
https://github.com/archtechx/enums.git
synced 2025-12-12 11:14:05 +00:00
Code style
This commit is contained in:
parent
7b0871db00
commit
ead6bda52f
5 changed files with 17 additions and 6 deletions
|
|
@ -11,6 +11,10 @@ parameters:
|
||||||
- Illuminate\Routing\Route
|
- Illuminate\Routing\Route
|
||||||
|
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
|
- '#Access to an undefined static property static\(ArchTech\\Enums\\Meta\\MetaProperty\)\:\:\$method#'
|
||||||
|
- '#invalid typehint type ArchTech\\Enums\\Metadata#'
|
||||||
|
- '#invalid typehint type Enum#'
|
||||||
|
- '#on an unknown class Enum#'
|
||||||
# -
|
# -
|
||||||
# message: '#Offset (.*?) does not exist on array\|null#'
|
# message: '#Offset (.*?) does not exist on array\|null#'
|
||||||
# paths:
|
# paths:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ArchTech\Enums\Meta;
|
namespace ArchTech\Enums\Meta;
|
||||||
|
|
||||||
use Attribute;
|
use Attribute;
|
||||||
|
|
@ -10,7 +12,8 @@ class Meta
|
||||||
/** @var MetaProperty[] */
|
/** @var MetaProperty[] */
|
||||||
public array $metaProperties;
|
public array $metaProperties;
|
||||||
|
|
||||||
public function __construct(array|string ...$metaProperties) {
|
public function __construct(array|string ...$metaProperties)
|
||||||
|
{
|
||||||
// When an array is passed, it'll be wrapped in an outer array due to the ...variadic parameter
|
// When an array is passed, it'll be wrapped in an outer array due to the ...variadic parameter
|
||||||
if (isset($metaProperties[0]) && is_array($metaProperties[0])) {
|
if (isset($metaProperties[0]) && is_array($metaProperties[0])) {
|
||||||
// Extract the inner array
|
// Extract the inner array
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ArchTech\Enums\Meta;
|
namespace ArchTech\Enums\Meta;
|
||||||
|
|
||||||
abstract class MetaProperty
|
abstract class MetaProperty
|
||||||
{
|
{
|
||||||
public function __construct(
|
final public function __construct(
|
||||||
public mixed $value,
|
public mixed $value,
|
||||||
) {
|
) {
|
||||||
$this->value = $this->transform($value);
|
$this->value = $this->transform($value);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ArchTech\Enums\Meta;
|
namespace ArchTech\Enums\Meta;
|
||||||
|
|
||||||
use ReflectionAttribute;
|
use ReflectionAttribute;
|
||||||
|
|
@ -11,7 +13,7 @@ class Reflection
|
||||||
/**
|
/**
|
||||||
* Get the meta properties enabled on an Enum.
|
* Get the meta properties enabled on an Enum.
|
||||||
*
|
*
|
||||||
* @param Enum&\ArchTech\Enums\Metadata $enum
|
* @param \Enum&\ArchTech\Enums\Metadata $enum
|
||||||
* @return string[]|array<\class-string<MetaProperty>>
|
* @return string[]|array<\class-string<MetaProperty>>
|
||||||
*/
|
*/
|
||||||
public static function metaProperties(mixed $enum): array
|
public static function metaProperties(mixed $enum): array
|
||||||
|
|
@ -34,9 +36,7 @@ class Reflection
|
||||||
/**
|
/**
|
||||||
* Get the value of a meta property on the provided enum.
|
* Get the value of a meta property on the provided enum.
|
||||||
*
|
*
|
||||||
* @param \class-string<MetaProperty> $property
|
* @param \Enum $enum
|
||||||
* @param Enum $enum
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public static function metaValue(string $metaProperty, mixed $enum): mixed
|
public static function metaValue(string $metaProperty, mixed $enum): mixed
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ArchTech\Enums;
|
namespace ArchTech\Enums;
|
||||||
|
|
||||||
use ArchTech\Enums\Meta\MetaProperty;
|
use ArchTech\Enums\Meta\MetaProperty;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue