akef / the-magic-dto
魔法 DTO
dev-master
2020-06-25 07:48 UTC
Requires
- php: ^7.0
This package is auto-updated.
Last update: 2024-09-25 17:05:32 UTC
README
此库提供了访问类属性的功能,使用设置器和获取器函数调用,而不需要实现它们。
安装
使用包管理器 composer 安装 The-Magic-DTO。
composer require akef/the-magic-dto:dev-master
使用方法
只需在您的类中使用此特性
use \Akef\MDTO\SetAndGetProvider;
或在您的类中调用魔法类 __call
魔法函数,如下所示
public function __call($name, $arguments) { return (new \Akef\MDTO\MagicManager())->init($this, $name, $arguments)->run(); }
示例
require 'vendor/autoload.php'; class Test { use \Akef\MDTO\SetAndGetProvider; private $foo; } $testObject = new Test(); $test->setFoo('It is working!'); $fooValue = $testObject->getFoo(); echo $fooValue; //It is working!
贡献
欢迎提交拉取请求。对于重大更改,请先打开一个问题来讨论您想要更改的内容。
请确保根据需要更新测试。