| Total Complexity | 11 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 4 | class EmptyTemplate implements Template |
||
| 5 | { |
||
| 6 | /** |
||
| 7 | * 值 |
||
| 8 | * |
||
| 9 | * @var array |
||
| 10 | */ |
||
| 11 | protected $value; |
||
| 12 | /** |
||
| 13 | * 继承 |
||
| 14 | * |
||
| 15 | * @var Template |
||
| 16 | */ |
||
| 17 | protected $extens; |
||
| 18 | |||
| 19 | public function get(string $name=null, $default=null) |
||
| 20 | { |
||
| 21 | if (is_null($name)) { |
||
| 22 | return $this->value; |
||
| 23 | } |
||
| 24 | return $this->value[$name] ?? $default; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function set(string $name, $value) |
||
| 28 | { |
||
| 29 | $this->value[$name] = $value; |
||
| 30 | return $this; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function has(string $name) |
||
| 34 | { |
||
| 35 | return \array_key_exists($name, $this->value); |
||
| 36 | } |
||
| 37 | |||
| 38 | public function assign(array $values) |
||
| 39 | { |
||
| 40 | $this->value=array_merge($this->value, $values); |
||
| 41 | return $this; |
||
| 42 | } |
||
| 43 | |||
| 44 | public function include(Template $template) |
||
| 45 | { |
||
| 46 | $template->assign($this->value); |
||
| 47 | $template->getRenderedString(); |
||
| 48 | } |
||
| 49 | |||
| 50 | public function extends(Template $template) |
||
| 51 | { |
||
| 52 | $this->extends = $template; |
||
|
|
|||
| 53 | } |
||
| 54 | |||
| 55 | public function insert(string $name, $callback) |
||
| 56 | { |
||
| 57 | } |
||
| 58 | |||
| 59 | public function exec(string $name) |
||
| 61 | } |
||
| 62 | |||
| 63 | public function getRenderedString() |
||
| 64 | { |
||
| 65 | $text = 'EmptyTemplate<'.$this->get('name', 'null').'>'; |
||
| 66 | if ($this->extends) { |
||
| 70 | } |
||
| 71 | } |
||
| 72 |