40,21 → 40,6 |
abstract class Base |
{ |
/** |
* Determines if a strict model is enforced. |
* |
* If <code>true</code>, all publicly accessible properties |
* must have a getter if readable, and a setter if writable. |
* Otherwise, accesses to non-existing public properties will be |
* forwarded to the correspnding underline property if no getter |
* or setter has been defined for it. The default is |
* <code>false</code> (non-strict) as that speeds up property |
* accesses and eases implementation considerably. |
* |
* @var bool |
*/ |
protected static $_strict = false; |
|
/** |
* Retrieves a property value. |
* |
* Automagically called when attempting to read data |
78,14 → 63,8 |
} |
|
if (property_exists($this, "_$name")) |
{ |
$class = get_class($this); |
if ($class::$_strict) |
{ |
throw new \InvalidArgumentException("Strict model: Property '{$name}' has no getter"); |
} |
|
return $this->{"_$name"}; |
{ |
throw new \InvalidArgumentException("Property '{$name}' has no getter"); |
} |
|
throw new \InvalidArgumentException("No such property: '{$name}'"); |
115,17 → 94,10 |
{ |
return $this->$setter($value); |
} |
|
|
if (property_exists($this, "_$name")) |
{ |
$class = get_class($this); |
if ($class::$_strict) |
{ |
throw new \InvalidArgumentException("Strict model: Property '{$name}' has no setter"); |
} |
|
$this->{"_$name"} = $value; |
return $value; |
throw new \InvalidArgumentException("Property '{$name}' has no setter"); |
} |
|
throw new \InvalidArgumentException("No such property: '{$name}'"); |