Some checks failed
Deploy Application / deploy (push) Has been cancelled
32 lines
846 B
PHP
32 lines
846 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\View\ValueObjects;
|
|
|
|
/**
|
|
* Helper functions for working with data attributes
|
|
*
|
|
* Provides convenience methods for converting data attribute enums to strings
|
|
* and working with both string and enum attribute names.
|
|
*/
|
|
final readonly class DataAttributeHelper
|
|
{
|
|
/**
|
|
* Convert attribute name to string
|
|
*
|
|
* Accepts both string and DataAttributeInterface for convenience.
|
|
* This allows methods to accept either format without requiring ->value() calls.
|
|
*
|
|
* @param string|DataAttributeInterface $attribute
|
|
* @return string
|
|
*/
|
|
public static function toString(string|DataAttributeInterface $attribute): string
|
|
{
|
|
return $attribute instanceof DataAttributeInterface
|
|
? $attribute->value()
|
|
: $attribute;
|
|
}
|
|
}
|
|
|