| Total Complexity | 6 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | class JsonAdapter extends ViewAdapterAbstract |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * Output method |
||
| 27 | * |
||
| 28 | * @param string $path Path to template |
||
| 29 | */ |
||
| 30 | 1 | public function show($path) |
|
| 31 | { |
||
| 32 | 1 | if (empty($this->variables)) { |
|
| 33 | 1 | return; |
|
| 34 | } |
||
| 35 | |||
| 36 | 1 | header('Content-Type: application/json'); |
|
| 37 | |||
| 38 | 1 | echo json_encode($this->variables); |
|
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Output View into buffer and save it in variable |
||
| 43 | * |
||
| 44 | * @param string $path Path to template |
||
| 45 | * |
||
| 46 | * @return string View content |
||
| 47 | */ |
||
| 48 | 1 | public function get($path) |
|
| 49 | { |
||
| 50 | 1 | foreach ($this->variables as $var_name => $value) { |
|
| 51 | 1 | $$var_name = $value; |
|
| 52 | } |
||
| 53 | |||
| 54 | 1 | ob_start(); |
|
| 55 | 1 | echo json_encode($this->variables); |
|
| 56 | 1 | $output = ob_get_contents(); |
|
| 57 | 1 | ob_end_clean(); |
|
| 58 | |||
| 59 | 1 | return $output; |
|
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Check template cache status |
||
| 64 | * |
||
| 65 | * @param string $tpl Template file |
||
| 66 | * |
||
| 67 | * @return bool Cache status |
||
| 68 | */ |
||
| 69 | 1 | public function isCached($tpl) |
|
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Driver initialization |
||
| 76 | */ |
||
| 77 | 3 | public function __construct() |
|
| 80 | } |
||
| 81 | } |
||
| 82 |