- Contains a accessor trait which allows to register accessors
- Contains a getter accessor, which means you don't have to write simple getters anymore
- Contains a is accessor, which means you don't have to write simple is anymore
- Contains a setter accessor, which means you don't have to write simple setters anymore
- PHP 5.4+
Through Composer as saxulum/accessor.
/**
* @method $this setName(string $name)
* @method string getName()
* @method boolean isName()
* @method $this setValue(string $value)
* @method string getValue()
* @method boolean isValue()
*/
class MyObject
{
use AccessorTrait;
/**
* @var string
*/
protected $name;
/**
* @var string
*/
protected $value;
public function __construct()
{
$this
->addAccessor(new GetterAccessor())
->addAccessor(new IsAccessor())
->addAccessor(new SetterAccessor())
;
}
}
$object = new MyObject();
$object
->setName('name')
->setValue('value')
;
$object->getName();
$object->getValue();
$object->isName();
$object->isValue();
- Dominik Zogg [email protected]