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

Convert::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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