| Total Complexity | 5 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class PageStatePresenter |
||
| 9 | { |
||
| 10 | /** @var StatefulContract */ |
||
| 11 | private $model; |
||
| 12 | |||
| 13 | /** @var PageState */ |
||
| 14 | private $pageState; |
||
| 15 | |||
| 16 | public function __construct(StatefulContract $model, PageState $pageState) |
||
| 17 | { |
||
| 18 | $this->model = $model; |
||
| 19 | $this->pageState = $pageState; |
||
| 20 | } |
||
| 21 | |||
| 22 | public static function fromModel(StatefulContract $model) |
||
| 23 | { |
||
| 24 | return new static($model, new PageState($model)); |
||
| 25 | } |
||
| 26 | |||
| 27 | public function render(): string |
||
| 28 | { |
||
| 29 | $class = $this->pageState->isOnline() ? 'text-success' : 'text-warning'; |
||
| 30 | |||
| 31 | return '<span class="inline-xs stack-s '.$class.'">' . $this->label() . '</span>'; |
||
| 32 | } |
||
| 33 | |||
| 34 | private function label() |
||
| 45 | } |
||
| 46 | } |
||
| 47 |