Completed
Push — master ( 89d65b...2465be )
by Ashley
68:37 queued 67:00
created

Convert   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 63
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 4 1
A setValue() 0 4 1
A __call() 0 11 2
A __callStatic() 0 6 1
1
<?php
2
3
namespace Clarkeash\Converter;
4
5
use BadMethodCallException;
6
use Clarkeash\Converter\Metrics\Size;
7
8
class Convert
9
{
10
    /**
11
     * @var array
12
     */
13
    protected static $metrics = [
14
        'size' => Size::class
15
    ];
16
17
    /**
18
     * @var int
19
     */
20
    protected $value = 0;
21
22
    /**
23
     * @return int
24
     */
25
    public function getValue()
26
    {
27
        return $this->value;
28
    }
29
30
    /**
31
     * @param int $value
32
     */
33
    public function setValue($value)
34
    {
35
        $this->value = $value;
36
    }
37
38
    /**
39
     * @param $method
40
     * @param $args
41
     *
42
     * @return mixed
43
     */
44
    public function __call($method, $args)
45
    {
46
        if (array_key_exists($method, static::$metrics)) {
47
48
            $metric = new static::$metrics[$method];
49
50
            return new From($this, $metric);
51
        }
52
53
        throw new BadMethodCallException(sprintf('Method: %s does not exist on class: %s', $method, get_class($this)));
54
    }
55
56
    /**
57
     * Proxy to __call
58
     *
59
     * @param $method
60
     * @param $args
61
     *
62
     * @return \Clarkeash\Converter\From
63
     */
64
    public static function __callStatic($method, $args)
65
    {
66
        $convert = new static;
67
68
        return call_user_func([$convert, $method]);
69
    }
70
}
71