Files
kulakpos_web/vendor/knuckleswtf/scribe/src/Attributes/Group.php
eko54r 1228c52538
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m36s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 42s
Build, Push and Deploy / deploy-production (push) Has been skipped
update after stop build
2026-04-18 16:10:57 +07:00

46 lines
1.1 KiB
PHP

<?php
namespace Knuckles\Scribe\Attributes;
use Attribute;
#[Attribute(Attribute::TARGET_FUNCTION | Attribute::TARGET_METHOD | Attribute::TARGET_CLASS)]
class Group
{
public function __construct(
public mixed $name,
public ?string $description = '',
/** You can use the separate #[Authenticated] attribute, or pass authenticated: false to this. */
public ?bool $authenticated = null,
) {}
public function toArray()
{
$data = [
'groupName' => $this->getName(),
'groupDescription' => $this->description,
];
if (! is_null($this->authenticated)) {
$data['authenticated'] = $this->authenticated;
}
return $data;
}
protected function getName(): string
{
if (is_string($this->name)) {
return $this->name;
}
if (interface_exists('BackedEnum') && is_a($this->name, 'BackedEnum')) {
return $this->name->value;
}
throw new \InvalidArgumentException(
'The name property of a group must be either a PHP Backed Enum or a string'
);
}
}