henzeb/enumhancer

View on GitHub
src/Concerns/Attributes.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace Henzeb\Enumhancer\Concerns;

use Henzeb\Enumhancer\Helpers\EnumAttributes;

trait Attributes
{
    protected function getAttribute(string $attributeClass): mixed
    {
        return EnumAttributes::fromCase(self::class, $this, $attributeClass);
    }

    protected function getAttributes(string $attributeClass = null): array
    {
        return EnumAttributes::fromCaseArray(self::class, $this, $attributeClass);
    }

    protected static function getEnumAttribute(string $attributeClass): mixed
    {
        return EnumAttributes::fromEnum(self::class, $attributeClass);
    }

    protected static function getEnumAttributes(string $attributeClass = null): array
    {
        return EnumAttributes::fromEnumArray(self::class, $attributeClass);
    }
}