2 /* This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
3 and is published under the AGPL license. */
9 protected $_data = array();
10 public function __construct($name = null, $data = array()) {
12 if (is_array($data)) {
17 public function getName() {
21 public function setName($name) {
22 $this->_name = (string)$name;
26 public function __set($property, $value) {
27 $this->_data[$property] = $value;
29 public function __get($property) {
30 if (array_key_exists($property, $this->_data)) {
31 return $this->_data[$property];
36 public function __unset($property) {
37 unset($this->_data[$property]);
39 public function __isset($property) {
40 return __isset($this->_data[$property]);
43 public function __toString() {
45 $prefix = "var " . $this->_name . " = ";
49 return $prefix . " " . json_encode($this->_data, JSON_FORCE_OBJECT) . ";" . PHP_EOL;