-
-
Notifications
You must be signed in to change notification settings - Fork 335
/
AnnotationToAttribute.php
51 lines (41 loc) · 1.11 KB
/
AnnotationToAttribute.php
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
49
50
51
<?php
declare(strict_types=1);
namespace Rector\Php80\ValueObject;
use Rector\Php80\Contract\ValueObject\AnnotationToAttributeInterface;
use Rector\Validation\RectorAssert;
use Webmozart\Assert\Assert;
final readonly class AnnotationToAttribute implements AnnotationToAttributeInterface
{
/**
* @param string[] $classReferenceFields
*/
public function __construct(
private string $tag,
private ?string $attributeClass = null,
private array $classReferenceFields = []
) {
RectorAssert::className($tag);
if (is_string($attributeClass)) {
RectorAssert::className($attributeClass);
}
Assert::allString($classReferenceFields);
}
public function getTag(): string
{
return $this->tag;
}
public function getAttributeClass(): string
{
if ($this->attributeClass === null) {
return $this->tag;
}
return $this->attributeClass;
}
/**
* @return string[]
*/
public function getClassReferenceFields(): array
{
return $this->classReferenceFields;
}
}