| Total Complexity | 4 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 26 | class View implements SplObserver |
||
| 27 | { |
||
| 28 | /** |
||
| 29 | * @var array<mixed> Data for the dynamic view |
||
| 30 | */ |
||
| 31 | protected array $data = []; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var TemplateInterface Template utilized for render data |
||
| 35 | */ |
||
| 36 | protected TemplateInterface $template; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var Model Model for access data |
||
| 40 | */ |
||
| 41 | protected Model $model; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Constructor. |
||
| 45 | * |
||
| 46 | * @param Model $model |
||
| 47 | */ |
||
| 48 | 16 | public function __construct(Model $model, TemplateInterface $template) |
|
| 49 | { |
||
| 50 | 16 | $this->model = $model; |
|
| 51 | 16 | $this->template = $template; |
|
| 52 | 16 | } |
|
| 53 | |||
| 54 | /** |
||
| 55 | * Render a template. |
||
| 56 | * |
||
| 57 | * @return string |
||
| 58 | */ |
||
| 59 | 19 | public function render(): string |
|
| 60 | { |
||
| 61 | 19 | $this->template->setData($this->data); |
|
| 62 | |||
| 63 | 19 | return $this->template->getOutput(); |
|
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Update Observer data. |
||
| 68 | * |
||
| 69 | * @param SplSubject $subject |
||
| 70 | * |
||
| 71 | * @return void |
||
| 72 | */ |
||
| 73 | 19 | public function update(SplSubject $subject) |
|
| 77 | } |
||
| 78 | 19 | } |
|
| 79 | } |
||
| 80 |