1 | <?php |
||
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 | 2 | public function getValue() |
|
29 | |||
30 | /** |
||
31 | * @param int $value |
||
32 | */ |
||
33 | 4 | public function setValue($value) |
|
37 | |||
38 | /** |
||
39 | * @param $method |
||
40 | * @param $args |
||
41 | * |
||
42 | * @return mixed |
||
43 | */ |
||
44 | 2 | public function __call($method, $args) |
|
45 | { |
||
46 | 2 | if (array_key_exists($method, static::$metrics)) { |
|
47 | |||
48 | 1 | $metric = new static::$metrics[$method]; |
|
49 | |||
50 | 1 | return new From($this, $metric); |
|
51 | } |
||
52 | |||
53 | 1 | 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 | 2 | public static function __callStatic($method, $args) |
|
70 | } |
||
71 |