76 lines
1.3 KiB
PHP
76 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace KupShop\FeedGeneratorBundle\Configuration\Nodes;
|
|
|
|
use KupShop\FeedGeneratorBundle\Expressions\ExpressionWrapper;
|
|
|
|
abstract class AbstractNode
|
|
{
|
|
/** @var string */
|
|
private $type;
|
|
|
|
/** @var string */
|
|
private $value;
|
|
|
|
/** @var string */
|
|
protected $valueHash;
|
|
|
|
/** @var INode[] */
|
|
private $nodes = [];
|
|
|
|
public function getType(): string
|
|
{
|
|
return $this->type;
|
|
}
|
|
|
|
public function setType(string $type)
|
|
{
|
|
$this->type = $type;
|
|
}
|
|
|
|
public function getValue(): string
|
|
{
|
|
return $this->value;
|
|
}
|
|
|
|
public function getValueHash(): string
|
|
{
|
|
if (!isset($this->valueHash)) {
|
|
$this->valueHash = md5(ExpressionWrapper::wrap($this->getValue()));
|
|
}
|
|
|
|
return $this->valueHash;
|
|
}
|
|
|
|
public function setValue(string $value)
|
|
{
|
|
$this->value = $value;
|
|
}
|
|
|
|
/**
|
|
* @return INode[]
|
|
*/
|
|
public function getNodes(): array
|
|
{
|
|
return $this->nodes;
|
|
}
|
|
|
|
/**
|
|
* @param INode[] $nodes
|
|
*/
|
|
public function setNodes(array $nodes)
|
|
{
|
|
$this->nodes = $nodes;
|
|
}
|
|
|
|
public function hasNodes(): bool
|
|
{
|
|
return count($this->nodes) > 0;
|
|
}
|
|
|
|
public function addNode(INode $node)
|
|
{
|
|
$this->nodes[] = $node;
|
|
}
|
|
}
|