2021-03-21 00:16:21 +01:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
declare (strict_types=1);
|
2022-06-06 17:12:56 +00:00
|
|
|
namespace Rector\Php80\ValueObject;
|
2021-03-21 00:16:21 +01:00
|
|
|
|
2022-08-18 17:55:50 +00:00
|
|
|
use Rector\Core\Validation\RectorAssert;
|
|
|
|
use Rector\Php80\Contract\ValueObject\AnnotationToAttributeInterface;
|
|
|
|
final class AnnotationToAttribute implements AnnotationToAttributeInterface
|
2021-03-21 00:16:21 +01:00
|
|
|
{
|
|
|
|
/**
|
2022-08-18 17:55:50 +00:00
|
|
|
* @var 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
|
|
|
/**
|
2022-08-18 17:55:50 +00:00
|
|
|
* @var string|null
|
2021-03-21 00:16:21 +01:00
|
|
|
*/
|
|
|
|
private $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;
|
2022-08-18 17:55:50 +00:00
|
|
|
RectorAssert::className($tag);
|
|
|
|
if (\is_string($attributeClass)) {
|
|
|
|
RectorAssert::className($attributeClass);
|
|
|
|
}
|
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
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|