for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace nebula\component\template;
use nebula\component\template\EchoValueInterface;
class Tag implements EchoValueInterface
{
use EchoValueTrait;
protected $content;
/**
* 配置信息
*
* @var array
*/
protected $config;
* 标签名
* @var string
protected $name;
* 开标签
protected $open;
* 闭标签
protected $close;
public function __construct(string $name, string $open, string $close, string $content)
$this->content = $content;
$this->name = $name;
$this->open = $open;
$this->close= $close;
}
public function compile(string $content):string
return $this->parseEchoValue(\str_replace('$code', $content, $this->content));
* Get 开标签
* @return string
public function getOpen()
return $this->open;
* Get 闭标签
public function getClose()
return $this->close;
* Set 闭标签
* @param string $close 闭标签
* @return self
public function setClose(string $close)
$this->close = $close;
return $this;
* Set 开标签
* @param string $open 开标签
public function setOpen(string $open)
* Get 标签名
public function getName()
return $this->name;
* Set 标签名
* @param string $name 标签名
public function setName(string $name)
* Set 配置信息
* @param array $config 配置信息
public function setConfig(array $config)
$this->config = $config;
if (array_key_exists('open', $config)) {
$this->setOpen($config['open']);
if (array_key_exists('close', $config)) {
$this->setClose($config['close']);