1 | <?php |
||
9 | class Convert |
||
10 | { |
||
11 | /** |
||
12 | * @var array |
||
13 | */ |
||
14 | protected static $metrics = [ |
||
15 | 'size' => Size::class, |
||
16 | 'time' => Time::class, |
||
17 | ]; |
||
18 | |||
19 | /** |
||
20 | * @var int |
||
21 | */ |
||
22 | protected $value = 0; |
||
23 | |||
24 | /** |
||
25 | * @return int |
||
26 | */ |
||
27 | 6 | public function getValue() |
|
31 | |||
32 | /** |
||
33 | * @param int $value |
||
34 | */ |
||
35 | 7 | public function setValue($value) |
|
39 | |||
40 | /** |
||
41 | * @param $method |
||
42 | * @param $args |
||
43 | * |
||
44 | * @return mixed |
||
45 | */ |
||
46 | 4 | public function __call($method, $args) |
|
47 | { |
||
48 | 4 | if (array_key_exists($method, static::$metrics)) { |
|
49 | |||
50 | 3 | $metric = new static::$metrics[$method]; |
|
51 | |||
52 | 3 | return new From($this, $metric); |
|
53 | } |
||
54 | |||
55 | 1 | BadMethodCallException::throw($method, $this); |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * Proxy to __call |
||
60 | * |
||
61 | * @param $method |
||
62 | * @param $args |
||
63 | * |
||
64 | * @return \Clarkeash\Converter\From |
||
65 | */ |
||
66 | 4 | public static function __callStatic($method, $args) |
|
72 | } |
||
73 |