slaxweb/getset
最新稳定版本:0.1.0
Composer 安装命令:
composer require slaxweb/getset
包简介
Getter and Setter traits for SlaxWeb Framework
README 文档
README
GetSet component provides the MagicGet and MagicSet traits that can be used to simplify and unify implementation of magic getter and setter.
Installation
Installation can be done through composer, just add slaxweb/getset package to your composer.json file:
{
"require": {
"slaxweb/getset": "0.1.*@dev"
}
}
Usage
Usage of MagicGet and MagicSet traits is pretty simple and straightforward, you just need to use them in your class, and writing and reading of your otherwise inaccessible properties is available. Both the MagicGet and MagicSet traits will prepend an underscore (_) to the name of the requested property. If you wish to alter or disable the prepend, then your class that uses those traits must define the _getSetPrepend property with the value you wish to prepend to the requested properties.
If the requested property does not exist, then both traits will throw the \SlaxWeb\Exception\UnknownPropertyException exception.
Example usage:
<?php class Foo { use SlaxWeb\GetSet\MagicGet; use SlaxWeb\GetSet\MagicSet; protected $__bar = ""; protected $_getSetPrepend = "__"; } $foo = new Foo; $foo->bar = "baz"; echo $foo->bar;
统计信息
- 总下载量: 921
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-28