2021-03-21 00:16:21 +01:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
declare (strict_types=1);
|
2021-03-21 00:16:21 +01:00
|
|
|
namespace Rector\Php80\ValueObject;
|
|
|
|
|
|
|
|
final class AnnotationToAttribute
|
|
|
|
{
|
|
|
|
/**
|
2021-08-22 21:22:18 +00:00
|
|
|
* @var class-string|string
|
2021-03-21 00:16:21 +01:00
|
|
|
*/
|
2021-04-04 11:01:11 +02:00
|
|
|
private $tag;
|
2021-03-21 00:16:21 +01:00
|
|
|
/**
|
2021-08-22 21:22:18 +00:00
|
|
|
* @var class-string
|
2021-03-21 00:16:21 +01:00
|
|
|
*/
|
|
|
|
private $attributeClass;
|
|
|
|
/**
|
2021-04-04 11:01:11 +02:00
|
|
|
* @param class-string|string $tag
|
2021-03-21 00:16:21 +01:00
|
|
|
* @param class-string $attributeClass
|
|
|
|
*/
|
2021-06-05 21:47:54 +00:00
|
|
|
public function __construct(string $tag, ?string $attributeClass = null)
|
2021-03-21 00:16:21 +01:00
|
|
|
{
|
2021-04-04 11:01:11 +02:00
|
|
|
$this->tag = $tag;
|
2021-03-21 00:16:21 +01:00
|
|
|
$this->attributeClass = $attributeClass;
|
|
|
|
}
|
|
|
|
/**
|
2021-04-04 11:01:11 +02:00
|
|
|
* @return class-string|string
|
2021-03-21 00:16:21 +01:00
|
|
|
*/
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getTag() : string
|
2021-03-21 00:16:21 +01:00
|
|
|
{
|
2021-04-04 11:01:11 +02:00
|
|
|
return $this->tag;
|
2021-03-21 00:16:21 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return class-string
|
|
|
|
*/
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getAttributeClass() : string
|
2021-03-21 00:16:21 +01:00
|
|
|
{
|
2021-06-05 21:47:54 +00:00
|
|
|
if ($this->attributeClass === null) {
|
|
|
|
return $this->tag;
|
|
|
|
}
|
2021-03-21 00:16:21 +01:00
|
|
|
return $this->attributeClass;
|
|
|
|
}
|
|
|
|
}
|