1 | <?php |
||
9 | class Client |
||
10 | { |
||
11 | /** |
||
12 | * @var Builder |
||
13 | */ |
||
14 | protected $builder; |
||
15 | /** |
||
16 | * @var array; |
||
17 | */ |
||
18 | protected $definitions = []; |
||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | private $config; |
||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $defaults = []; |
||
27 | |||
28 | /** |
||
29 | * Client constructor. |
||
30 | * |
||
31 | * @param $config |
||
32 | */ |
||
33 | 18 | public function __construct($config) |
|
37 | |||
38 | /** |
||
39 | * Check if we can call a method on the manipulations builder. |
||
40 | * Else check if a predefined manipulation set need to be called. |
||
41 | * |
||
42 | * @param string $method |
||
43 | * @param array $arguments |
||
44 | * @return $this |
||
45 | * @throws UndefinedDefinitionException |
||
46 | */ |
||
47 | 13 | public function __call($method, $arguments) |
|
63 | |||
64 | /** |
||
65 | * Define a predefined set of manipulations. |
||
66 | * |
||
67 | * @param string $key |
||
68 | * @param Closure $callback |
||
69 | * @return $this |
||
70 | */ |
||
71 | 2 | public function define($key, Closure $callback) |
|
77 | |||
78 | /** |
||
79 | * Let the client fetch the given url as image. |
||
80 | * |
||
81 | * @param string $url |
||
82 | * @return $this |
||
83 | */ |
||
84 | 18 | public function fetch($url) |
|
96 | |||
97 | /** |
||
98 | * Set the default dpr. |
||
99 | * |
||
100 | * @param string $key |
||
101 | * @param mixed $value |
||
102 | * @return $this |
||
103 | */ |
||
104 | 2 | public function setDefault($key, $value) |
|
110 | |||
111 | /** |
||
112 | * Retrieve the imaginary url. |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | 17 | public function url() |
|
135 | |||
136 | /** |
||
137 | * Get the resource key. |
||
138 | * We currently only support image. |
||
139 | * |
||
140 | * @return string |
||
141 | */ |
||
142 | 14 | protected function getResourceKey() |
|
146 | |||
147 | /** |
||
148 | * Get the type key. |
||
149 | * We only support fetch at the moment. |
||
150 | * |
||
151 | * @return string |
||
152 | */ |
||
153 | 14 | protected function getTypeKey() |
|
157 | |||
158 | /** |
||
159 | * Return the url for this image. |
||
160 | * |
||
161 | * @return string |
||
162 | */ |
||
163 | 1 | public function __toString() |
|
167 | } |