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 | /** |
||
25 | * Client constructor. |
||
26 | * |
||
27 | * @param $config |
||
28 | */ |
||
29 | 15 | public function __construct($config) |
|
33 | |||
34 | /** |
||
35 | * Check if we can call a method on the manipulations builder. |
||
36 | * Else check if a predefined manipulation set need to be called. |
||
37 | * |
||
38 | * @param string $method |
||
39 | * @param array $arguments |
||
40 | * @return $this |
||
41 | * @throws UndefinedDefinitionException |
||
42 | */ |
||
43 | 11 | public function __call($method, $arguments) |
|
59 | |||
60 | /** |
||
61 | * Define a predefined set of manipulations. |
||
62 | * |
||
63 | * @param string $key |
||
64 | * @param Closure $callback |
||
65 | * @return $this |
||
66 | */ |
||
67 | 2 | public function define($key, Closure $callback) |
|
73 | |||
74 | /** |
||
75 | * Let the client fetch the given url as image. |
||
76 | * |
||
77 | * @param string $url |
||
78 | * @return $this |
||
79 | */ |
||
80 | 15 | public function fetch($url) |
|
86 | |||
87 | /** |
||
88 | * Retrieve the imaginary url. |
||
89 | * |
||
90 | * @return string |
||
91 | * @throws InvalidConfigurationException |
||
92 | */ |
||
93 | 14 | public function url() |
|
112 | |||
113 | /** |
||
114 | * Get the resource key. |
||
115 | * We currently only support image. |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | 11 | protected function getResourceKey() |
|
123 | |||
124 | /** |
||
125 | * Get the type key. |
||
126 | * We only support fetch at the moment. |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | 11 | protected function getTypeKey() |
|
134 | |||
135 | /** |
||
136 | * Return the url for this image. |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | 1 | public function __toString() |
|
144 | } |