AbstractObjectExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 33
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasMethod() 0 3 1
A methodReturnedRawResult() 0 7 2
A runMethod() 0 9 1
1
<?php namespace BuildR\Utils\Extension;
2
3
/**
4
 * AbstractObjectExtension
5
 *
6
 * BuildR PHP Framework
7
 *
8
 * @author Zoltán Borsos <[email protected]>
9
 * @package Utils
10
 * @subpackage Extension
11
 *
12
 * @copyright    Copyright 2016, Zoltán Borsos.
13
 * @license      https://github.com/BuildrPHP/Utils/blob/master/LICENSE.md
14
 * @link         https://github.com/BuildrPHP/Utils
15
 */
16
abstract class AbstractObjectExtension implements ObjectExtensionInterface {
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 2
    public function hasMethod($methodName) {
22 2
        return array_key_exists($methodName, $this->defineMethods());
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 2
    public function methodReturnedRawResult($methodName) {
29 2
        if($this->hasMethod($methodName)) {
30 2
            return (bool) $this->defineMethods()[$methodName]['returnsRaw'];
31
        }
32
33
        return TRUE; //@codeCoverageIgnore
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 2
    public function runMethod($methodName, $startingValue, array $additionalArguments) {
40 2
        $args = $additionalArguments;
41 2
        array_unshift($args, $startingValue);
42
43 2
        $methodReturnsAsRaw = $this->methodReturnedRawResult($methodName);
44 2
        $result = call_user_func_array([$this, $methodName], $args);
45
46 2
        return ['result' => $result, 'rawResult' => $methodReturnsAsRaw];
47
    }
48
}
49