henzeb/enumhancer

View on GitHub
src/Concerns/ConfigureLabels.php

Summary

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

namespace Henzeb\Enumhancer\Concerns;

use Henzeb\Enumhancer\Helpers\EnumProperties;
use Henzeb\Enumhancer\Exceptions\ReservedPropertyNameException;
use Henzeb\Enumhancer\Exceptions\PropertyAlreadyStoredException;

trait ConfigureLabels
{
    /**
     * @throws ReservedPropertyNameException|PropertyAlreadyStoredException
     */
    public static function setLabels(array $labels): void
    {
        EnumProperties::store(
            self::class,
            EnumProperties::reservedWord('labels'),
            $labels,
            true,
        );
    }

    /**
     * @throws ReservedPropertyNameException|PropertyAlreadyStoredException
     */
    public static function setLabelsOnce(array $labels): void
    {
        EnumProperties::storeOnce(
            self::class,
            EnumProperties::reservedWord('labels'),
            $labels,
            true,
        );
    }
}