| 1 | <?php |
||
| 26 | class Template |
||
|
|
|||
| 27 | { |
||
| 28 | /** |
||
| 29 | * Vars used in the template |
||
| 30 | * |
||
| 31 | * @Array |
||
| 32 | */ |
||
| 33 | private $_vars; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Template file |
||
| 37 | * |
||
| 38 | * @String |
||
| 39 | */ |
||
| 40 | private $_file; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Constructor |
||
| 44 | * |
||
| 45 | * @param String $file the template file name |
||
| 46 | */ |
||
| 47 | public function __construct($file=null) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Set a template variable. |
||
| 55 | * |
||
| 56 | * @param string variable name |
||
| 57 | * @param string variable value |
||
| 58 | */ |
||
| 59 | public function set($name, $value) |
||
| 60 | { |
||
| 61 | $this->_vars[$name] = is_object($value) ? $value->fetch() : $value; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Open, parse, and return the template file. |
||
| 66 | * |
||
| 67 | * @param string $file |
||
| 68 | * |
||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | public function fetch($file=null) |
||
| 93 | } |
||
| 94 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.