ilya / dynamic
语法糖,人人可用。
1.0.0
2014-05-10 08:56 UTC
Requires (Dev)
- phpspec/phpspec: ~2
This package is not auto-updated.
Last update: 2024-09-14 15:54:08 UTC
README
语法糖,人人可用。
Dynamic可以帮助你处理对不存在方法的调用。
示例
<?php require __DIR__.'/../vendor/autoload.php'; use Dynamic\DynamicTrait; class Example { use DynamicTrait; public function __construct() { $this->getDynamicInstance()->redirect('/^say(\w+)To$/', 'say'); } public function say($what, $to) { echo ucfirst("$what, $to!"), PHP_EOL; } } $example = new Example; echo $example->sayHelloTo('Jack'), $example->sayByeTo('John');
你能猜到输出结果吗?自己看看吧!
git clone https://github.com/ilya-dev/dynamic.git
cd dynamic
php examples/first.php
文档
别忘了将 Dynamic\DynamicTrait
特性添加到你的类中。
void redirect(string $pattern, string $method)
mixed handle(mixed $instance, string $method, array $arguments = [])
安装
php composer.phar require "ilya/dynamic:~1"
许可
Dynamic遵循MIT许可协议。