Completed
Push — master ( 798ed3...31d6a2 )
by Dmitry
01:44
created

Procedure   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
getBody() 0 1 ?
getParams() 0 1 ?
A getName() 0 6 1
A getMapping() 0 4 1
A __invoke() 0 13 3
1
<?php
2
3
namespace Tarantool\Mapper;
4
5
use Tarantool\Mapper\Plugin\Procedure as ProcedurePlugin;
6
7
abstract class Procedure
8
{
9
    private $plugin;
10
11
    public function __construct(ProcedurePlugin $plugin)
12
    {
13
        $this->plugin = $plugin;
14
    }
15
16
    abstract public function getBody() : string;
17
    abstract public function getParams() : array;
18
19
    public function getName() : string
20
    {
21
        $class = get_class($this);
22
        $name = str_replace("Procedure\\", '', $class);
23
        return strtolower(implode('_', explode('\\', $name)));
24
    }
25
26
    public function getMapping() : array
27
    {
28
        return [];
29
    }
30
31
    public function __invoke()
32
    {
33
        $raw = $this->plugin->invoke($this, func_get_args());
34
        if (!count($this->getMapping())) {
35
            return $raw;
36
        }
37
38
        $result = [];
39
        foreach ($this->getMapping() as $i => $name) {
40
            $result[$name] = $raw[$i];
41
        }
42
        return $result;
43
    }
44
}
45