2019-10-13 07:59:52 +02:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
declare (strict_types=1);
|
2019-07-16 11:07:26 +02:00
|
|
|
namespace Rector\CodingStyle\ValueObject;
|
|
|
|
|
|
|
|
use PhpParser\Node;
|
|
|
|
use PhpParser\Node\Expr;
|
|
|
|
final class ConcatExpressionJoinData
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string[]
|
|
|
|
*/
|
|
|
|
private $values = [];
|
|
|
|
/**
|
|
|
|
* @var Node[]
|
|
|
|
*/
|
|
|
|
private $nodesToRemove = [];
|
|
|
|
/**
|
|
|
|
* @var Expr[]
|
|
|
|
*/
|
|
|
|
private $placeholdersToNodes = [];
|
2021-05-09 20:15:43 +00:00
|
|
|
public function addString(string $value) : void
|
2019-07-16 11:07:26 +02:00
|
|
|
{
|
|
|
|
$this->values[] = $value;
|
|
|
|
}
|
2021-05-10 22:23:08 +00:00
|
|
|
public function addNodeToRemove(\PhpParser\Node $node) : void
|
2019-07-16 11:07:26 +02:00
|
|
|
{
|
|
|
|
$this->nodesToRemove[] = $node;
|
|
|
|
}
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getString() : string
|
2019-07-16 11:07:26 +02:00
|
|
|
{
|
2021-05-09 20:15:43 +00:00
|
|
|
return \implode('', $this->values);
|
2019-07-16 11:07:26 +02:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return Node[]
|
|
|
|
*/
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getNodesToRemove() : array
|
2019-07-16 11:07:26 +02:00
|
|
|
{
|
|
|
|
return $this->nodesToRemove;
|
|
|
|
}
|
2021-05-10 22:23:08 +00:00
|
|
|
public function addPlaceholderToNode(string $objectHash, \PhpParser\Node\Expr $expr) : void
|
2019-07-16 11:07:26 +02:00
|
|
|
{
|
|
|
|
$this->placeholdersToNodes[$objectHash] = $expr;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return Expr[]
|
|
|
|
*/
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getPlaceholdersToNodes() : array
|
2019-07-16 11:07:26 +02:00
|
|
|
{
|
|
|
|
return $this->placeholdersToNodes;
|
|
|
|
}
|
|
|
|
}
|