1 | <?php |
||
12 | class Unsplash extends HttpClient |
||
13 | { |
||
14 | use UnsplashAPI; |
||
15 | |||
16 | /** |
||
17 | * Accepted url keys from response. |
||
18 | */ |
||
19 | const PHOTO_KEYS = [ |
||
20 | 'raw', |
||
21 | 'full', |
||
22 | 'regular', |
||
23 | 'small', |
||
24 | 'thumb', |
||
25 | ]; |
||
26 | |||
27 | /** |
||
28 | * Storage disk to store photos. |
||
29 | */ |
||
30 | protected $storage; |
||
31 | |||
32 | /** |
||
33 | * Guzzle response. |
||
34 | */ |
||
35 | protected $response; |
||
36 | |||
37 | /** |
||
38 | * Storage disk to store photos. |
||
39 | */ |
||
40 | protected $storeInDatabase; |
||
41 | |||
42 | /** |
||
43 | * Creates a new instance of Unsplash. |
||
44 | * |
||
45 | * @return MarkSitko\LaravelUnsplash\Unsplash |
||
|
|||
46 | */ |
||
47 | public function __construct() |
||
55 | |||
56 | /** |
||
57 | * Checks if the accessed property exists as a method |
||
58 | * if exists, call the get() method and return the complete response. |
||
59 | */ |
||
60 | public function __get($param) |
||
66 | |||
67 | /** |
||
68 | * Returns the full http response. |
||
69 | * |
||
70 | * @return GuzzleHttp\Psr7\Response |
||
71 | */ |
||
72 | public function get() |
||
78 | |||
79 | /** |
||
80 | * Returns the http response body. |
||
81 | * |
||
82 | * @return object |
||
83 | */ |
||
84 | public function toJson() |
||
90 | |||
91 | /** |
||
92 | * Returns the http response body. |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | public function toArray() |
||
102 | |||
103 | /** |
||
104 | * Returns the http response body as collection. |
||
105 | * |
||
106 | * @return \Illuminate\Support\Collection |
||
107 | */ |
||
108 | public function toCollection() |
||
114 | |||
115 | /** |
||
116 | * Stores the retrieving photo in the storage. |
||
117 | * |
||
118 | * @param string $name If no name is provided, a random 24 Charachter name will be generated |
||
119 | * @param string $key Defines the size of the retrieving photo |
||
120 | * |
||
121 | * @return string The stored photo name |
||
122 | */ |
||
123 | public function store($name = null, $key = 'small') |
||
154 | |||
155 | /** |
||
156 | * Builds the http request. |
||
157 | * |
||
158 | * @return MarkSitko\LaravelUnsplash\Unsplash |
||
159 | */ |
||
160 | protected function buildResponse() |
||
167 | |||
168 | /** |
||
169 | * Initalize storage. |
||
170 | * |
||
171 | * @return MarkSitko\LaravelUnsplash\Unsplash |
||
172 | */ |
||
173 | private function initalizeConfiguration() |
||
180 | } |
||
181 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.