Completed
Push — master ( a96253...c20805 )
by Nikolas
02:38
created

MethodAction::description()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
namespace rtens\domin\reflection;
3
4
use rtens\domin\reflection\types\TypeFactory;
5
use watoki\reflect\MethodAnalyzer;
6
7
class MethodAction extends StaticMethodAction {
8
9
    /** @var object */
10
    private $object;
11
12
    /**
13
     * @param object $object
14
     * @param string $method
15
     * @param TypeFactory $types
16
     * @param CommentParser $parser
17
     */
18
    public function __construct($object, $method, TypeFactory $types, CommentParser $parser) {
19
        parent::__construct(new \ReflectionMethod(get_class($object), $method), $types, $parser);
20
        $this->object = $object;
21
    }
22
23
    /**
24
     * @param mixed[] $parameters Values indexed by name
25
     * @return mixed the result of the execution
26
     * @throws \Exception if Action cannot be executed
27
     */
28
    public function execute(array $parameters) {
29
        $injector = function () {
30
        };
31
        $filter = function () {
32
            return true;
33
        };
34
35
        $analyzer = new MethodAnalyzer($this->method);
36
        $arguments = $analyzer->fillParameters($parameters, $injector, $filter);
37
38
        return $this->method->invokeArgs($this->object, $arguments);
39
    }
40
}