Completed
Push — master ( 4c8d32...c7efbc )
by James Ekow Abaka
04:08
created

Operations   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 83.33%

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 7
c 5
b 1
f 0
lcom 1
cbo 3
dl 0
loc 52
ccs 15
cts 18
cp 0.8333
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 4 1
A getInvalidFields() 0 4 1
A __construct() 0 7 1
A perform() 0 12 4
1
<?php
2
3
namespace ntentan\nibii;
4
5
class Operations
6
{
7
    private $wrapper;
8
    /**
9
     *
10
     * @var \ntentan\nibii\DriverAdapter
11
     */
12
    private $adapter;
13
    private $queryOperations;
14
    private $dataOperations;
15
    
16
    private $queryOperationMethods = [
17
        'fetch',    'fetchFirst',   'filter',   'query',    'fields', 
18
        'cover',    'limit',        'offset',   'filterBy', 'sortBy',
19
        'delete',   'count',        'update'
20
    ];
21
    
22
    private $dataOperationMethods = [
23
        'save'
24
    ];
25
    
26 34
    public function __construct($wrapper, $adapter)
27
    {
28 34
        $this->wrapper = $wrapper;
29 34
        $this->adapter = $adapter;
30 34
        $this->dataOperations = new DataOperations($wrapper, $adapter);
31 34
        $this->queryOperations = new QueryOperations($wrapper, $adapter, $this->dataOperations);
32 34
    }
33
34 34
    public function perform($name, $arguments)
35
    {
36 34
        if (array_search($name, $this->queryOperationMethods) !== false) {
37 30
            return call_user_func_array([$this->queryOperations, "do$name"], $arguments);
38 18
        } else if (array_search($name, $this->dataOperationMethods) !== false){
39 10
            return call_user_func_array([$this->dataOperations, "do$name"], $arguments);
40 10
        } else if($this->queryOperations->initDynamicMethod($name)) {
41 10
            return $this->queryOperations->runDynamicMethod($arguments);
42
        } else {
43
            throw new NibiiException("Method {$name} not found");
44
        }
45
    }
46
    
47
    public function getData() 
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
48
    {
49
        return $this->dataOperations->getData();
50
    }
51
    
52 10
    public function getInvalidFields()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
53
    {
54 10
        return $this->dataOperations->getInvalidFields();
55
    }
56
}
57