-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathEnumType.php
More file actions
48 lines (41 loc) · 1.13 KB
/
EnumType.php
File metadata and controls
48 lines (41 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types=1);
namespace TheCodingMachine\GraphQLite\Annotations;
use Attribute;
/**
* The EnumType annotation is useful to change the name of the generated "enum" type.
*
* @deprecated Use @Type on a native PHP 8.1 Enum instead. Support will be removed in future release.
*
* @Annotation
* @Target({"CLASS"})
* @Attributes({
* @Attribute("name", type = "string"),
* })
*/
#[Attribute(Attribute::TARGET_CLASS)]
class EnumType
{
private string|null $name;
private bool $useValues;
/** @param mixed[] $attributes */
public function __construct(array $attributes = [], string|null $name = null, bool|null $useValues = null)
{
$this->name = $name ?? $attributes['name'] ?? null;
$this->useValues = $useValues ?? $attributes['useValues'] ?? false;
}
/**
* Returns the GraphQL name for this type.
*/
public function getName(): string|null
{
return $this->name;
}
/**
* Returns true if the enum type should expose backed values instead of case names.
*/
public function useValues(): bool
{
return $this->useValues;
}
}