for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Equip\Data\Traits;
use RuntimeException;
trait ProtectedValueObjectTrait
{
/**
* Checks if a property is defined in the object
*
* This will return `false` if the value is `null`! To check if a value
* exists in the object, use `has()`.
* @param string $key
* @return boolean
*/
public function __isset($key)
return isset($this->$key);
}
* Allow read access to immutable object properties
* @return mixed
public function __get($key)
return $this->$key;
* Protects against the object being modified
* @param mixed $value
* @return void
* @throws \RuntimeException
public function __set($key, $value)
$key
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$value
throw new RuntimeException(sprintf(
'Modification of immutable object `%s` is not allowed',
get_class($this)
));
public function __unset($key)
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.