-
Notifications
You must be signed in to change notification settings - Fork 0
/
View.php
45 lines (38 loc) · 1001 Bytes
/
View.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php namespace Devtools;
use Exception;
abstract class View
{
protected $stylesheetCollection;
protected $scriptCollection;
protected $body;
public function __get($property)
{
switch($property) {
case 'stylesheet':
case 'script':
return $this->processCollection($property);
default:
return $this->$property;
}
}
private function processCollection($property)
{
$collection = $property.'Collection';
if (!is_array($this->$collection)) {
return self::$property($this->$collection);
}
$result = '';
foreach ($this->$collection as $item) {
$result .= self::$property($item);
}
return $result;
}
public static function stylesheet($path)
{
return "<link rel='stylesheet' href='{$path}'>\n";
}
public static function script($path)
{
return "<script src='{$path}'></script>\n";
}
}