Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
11 / 11 |
NoticeTwigView | |
100.00% |
1 / 1 |
|
100.00% |
7 / 7 |
7 | |
100.00% |
11 / 11 |
render | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
getTemplate | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
setTemplate | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
getContext | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
setContext | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
getTwigEnvironment | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
setTwigEnvironment | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
<?php | |
declare(strict_types=1); | |
namespace Korobochkin\WPKit\Notices; | |
use Twig\Environment; | |
/** | |
* Class NoticeTwigView | |
*/ | |
class NoticeTwigView implements NoticeViewInterface, NoticeTwigViewInterface | |
{ | |
/** | |
* @var string Twig template (path). | |
*/ | |
protected $template = ''; | |
/** | |
* @var string[] Array with variables. | |
*/ | |
protected $context = array(); | |
/** | |
* @var Environment Twig. | |
*/ | |
protected $twigEnvironment; | |
/** | |
* @inheritdoc | |
*/ | |
public function render(NoticeInterface $notice) | |
{ | |
echo $this->getTwigEnvironment()->render($this->getTemplate(), $this->getContext()); | |
} | |
/** | |
* @inheritdoc | |
*/ | |
public function getTemplate() | |
{ | |
return $this->template; | |
} | |
/** | |
* @inheritdoc | |
*/ | |
public function setTemplate($template) | |
{ | |
$this->template = $template; | |
return $this; | |
} | |
/** | |
* @inheritdoc | |
*/ | |
public function getContext() | |
{ | |
return $this->context; | |
} | |
/** | |
* @inheritdoc | |
*/ | |
public function setContext(array $context) | |
{ | |
$this->context = $context; | |
return $this; | |
} | |
/** | |
* @inheritdoc | |
*/ | |
public function getTwigEnvironment() | |
{ | |
return $this->twigEnvironment; | |
} | |
/** | |
* @inheritdoc | |
*/ | |
public function setTwigEnvironment(Environment $twigEnvironment) | |
{ | |
$this->twigEnvironment = $twigEnvironment; | |
return $this; | |
} | |
} |