dev-master
9999999-dev https://github.com/jongpak/prob-handlerA simple library for calling function and method
MIT
The Requires
- php >=7.0
The Development Requires
function handler method call prodecure
A simple library for calling function and method
A simple library for calling function and method, (*1)
<?php use Prob\Handler\ProcFactory; $procA = ProcFactory::getProc('pi'); echo $pro; // 3.141592... $procB = ProcFactory::getProc('abs'); echo $proc->exec(-32); // 32
<?php use Prob\Handler\ProcFactory; $proc = ProcFactory::getProc('testFunc', 'Apple\\Banana'); print_r($proc->exec('one', 'two', 'three')); // Array ( 'three', 'two', 'one' )
someFunc.php, (*3)
<?php namespace Apple\Banana; function testFunc($a, $b, $c) { return [$c, $b, $a]; }
<?php use Prob\Handler\ProcFactory; $proc = ProcFactory::getProc('Orange.testFunc', 'Apple\\Banana'); echo $proc->exec(10, 5); // 15
someClass.php, (*4)
<?php namespace Apple\Banana; class Orange { public function testFunc($a, $b) { return $a + $b; } }
<?php use Prob\Handler\ProcFactory; use Prob\Handler\ParameterMap; use Prob\Handler\Parameter\Named; use Prob\Handler\Parameter\Typed; use Prob\Handler\Parameter\TypedAndNamed; use Apple\Banana\ValueObject; $proc = ProcFactory::getProc('testFuncWithBinding', 'Apple\\Banana'); $vo = new ValueObject(); $vo->value = 'Welcome '; $parameterMap = new ParameterMap(); $parameterMap->bindBy(new Named('arg3'), 'World!'); $parameterMap->bindBy(new Typed('array'), ['str' => 'Hello']); $parameterMap->bindBy(new TypedAndNamed(ValueObject::class, 'arg1'), $vo); // Welcome HelloWorld! echo $proc->execWithParameterMap($parameterMap);
someFuncWithBinding.php, (*5)
<?php namespace Apple\Banana; function testFuncWithBinding(ValueObject $arg1, array $arg2, $arg3) { return $arg1->value . $arg2['str'] . $arg3; } class ValueObject { public $value; }
A simple library for calling function and method
MIT
function handler method call prodecure