@@ -11,7 +11,6 @@ |
||
11 | 11 | namespace DirkGroenen\Pinterest\Transport; |
12 | 12 | |
13 | 13 | use DirkGroenen\Pinterest\Utils\CurlBuilder; |
14 | -use DirkGroenen\Pinterest\Exceptions\PinterestException; |
|
15 | 14 | |
16 | 15 | class Response { |
17 | 16 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 Dirk Groenen |
|
4 | - * |
|
5 | - * (c) Dirk Groenen <[email protected]> |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Copyright 2015 Dirk Groenen |
|
4 | + * |
|
5 | + * (c) Dirk Groenen <[email protected]> |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace DirkGroenen\Pinterest\Endpoints; |
12 | 12 |
@@ -44,15 +44,15 @@ discard block |
||
44 | 44 | * @param array|Transport\Response $modeldata |
45 | 45 | * @return void |
46 | 46 | */ |
47 | - public function __construct( Pinterest $master, $modeldata = null ) |
|
47 | + public function __construct(Pinterest $master, $modeldata = null) |
|
48 | 48 | { |
49 | 49 | $this->master = $master; |
50 | 50 | |
51 | 51 | // Fill the model |
52 | - if( is_array($modeldata) ){ |
|
52 | + if (is_array($modeldata)) { |
|
53 | 53 | $this->fill($modeldata); |
54 | 54 | } |
55 | - else if( $modeldata instanceof \DirkGroenen\Pinterest\Transport\Response ){ |
|
55 | + else if ($modeldata instanceof \DirkGroenen\Pinterest\Transport\Response) { |
|
56 | 56 | $this->fill($modeldata->data); |
57 | 57 | } |
58 | 58 | } |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function __set($key, $value) |
82 | 82 | { |
83 | - if($this->isFillable($key)){ |
|
83 | + if ($this->isFillable($key)) { |
|
84 | 84 | $this->attributes[$key] = $value; |
85 | 85 | } |
86 | - else{ |
|
87 | - throw new PinterestException( sprintf("%s is not a fillable attribute.", $key) ); |
|
86 | + else { |
|
87 | + throw new PinterestException(sprintf("%s is not a fillable attribute.", $key)); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | */ |
109 | 109 | private function fill(array $attributes) |
110 | 110 | { |
111 | - foreach($attributes as $key => $value){ |
|
112 | - if($this->isFillable($key)){ |
|
111 | + foreach ($attributes as $key => $value) { |
|
112 | + if ($this->isFillable($key)) { |
|
113 | 113 | $this->attributes[$key] = $value; |
114 | 114 | } |
115 | 115 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | { |
138 | 138 | $array = array(); |
139 | 139 | |
140 | - foreach($this->fillable as $key){ |
|
140 | + foreach ($this->fillable as $key) { |
|
141 | 141 | $array[$key] = $this->{$key}; |
142 | 142 | } |
143 | 143 |
@@ -51,8 +51,7 @@ discard block |
||
51 | 51 | // Fill the model |
52 | 52 | if( is_array($modeldata) ){ |
53 | 53 | $this->fill($modeldata); |
54 | - } |
|
55 | - else if( $modeldata instanceof \DirkGroenen\Pinterest\Transport\Response ){ |
|
54 | + } else if( $modeldata instanceof \DirkGroenen\Pinterest\Transport\Response ){ |
|
56 | 55 | $this->fill($modeldata->data); |
57 | 56 | } |
58 | 57 | } |
@@ -82,8 +81,7 @@ discard block |
||
82 | 81 | { |
83 | 82 | if($this->isFillable($key)){ |
84 | 83 | $this->attributes[$key] = $value; |
85 | - } |
|
86 | - else{ |
|
84 | + } else{ |
|
87 | 85 | throw new PinterestException( sprintf("%s is not a fillable attribute.", $key) ); |
88 | 86 | } |
89 | 87 | } |
@@ -11,7 +11,6 @@ |
||
11 | 11 | namespace DirkGroenen\Pinterest\Transport; |
12 | 12 | |
13 | 13 | use DirkGroenen\Pinterest\Utils\CurlBuilder; |
14 | -use DirkGroenen\Pinterest\Exceptions\PinterestException; |
|
15 | 14 | |
16 | 15 | class Response { |
17 | 16 |
@@ -80,7 +80,7 @@ |
||
80 | 80 | $this->items = $items->data; |
81 | 81 | } |
82 | 82 | else{ |
83 | - throw new PinterestException("$items needs to be an instance of Transport\Response or an array."); |
|
83 | + throw new PinterestException("$items needs to be an instance of Transport\Response or an array."); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // Transform the raw collection data to models |
@@ -67,19 +67,18 @@ discard block |
||
67 | 67 | // Create class path |
68 | 68 | $this->model = ucfirst(strtolower($model)); |
69 | 69 | |
70 | - if (!class_exists("\\DirkGroenen\\Pinterest\\Models\\" . $this->model)) |
|
71 | - throw new InvalidModelException; |
|
70 | + if (!class_exists("\\DirkGroenen\\Pinterest\\Models\\" . $this->model)) { |
|
71 | + throw new InvalidModelException; |
|
72 | + } |
|
72 | 73 | |
73 | 74 | // Get items and response instance |
74 | 75 | if (is_array($items)) { |
75 | 76 | $this->response = null; |
76 | 77 | $this->items = $items; |
77 | - } |
|
78 | - else if ($items instanceof \DirkGroenen\Pinterest\Transport\Response) { |
|
78 | + } else if ($items instanceof \DirkGroenen\Pinterest\Transport\Response) { |
|
79 | 79 | $this->response = $items; |
80 | 80 | $this->items = $items->data; |
81 | - } |
|
82 | - else { |
|
81 | + } else { |
|
83 | 82 | throw new PinterestException("$items needs to be an instance of Transport\Response or an array."); |
84 | 83 | } |
85 | 84 | |
@@ -89,8 +88,7 @@ discard block |
||
89 | 88 | // Add pagination object |
90 | 89 | if (isset($this->response->page) && !empty($this->response->page['next'])) { |
91 | 90 | $this->pagination = $this->response->page; |
92 | - } |
|
93 | - else { |
|
91 | + } else { |
|
94 | 92 | $this->pagination = false; |
95 | 93 | } |
96 | 94 | } |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 Dirk Groenen |
|
4 | - * |
|
5 | - * (c) Dirk Groenen <[email protected]> |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Copyright 2015 Dirk Groenen |
|
4 | + * |
|
5 | + * (c) Dirk Groenen <[email protected]> |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace DirkGroenen\Pinterest\Endpoints; |
12 | 12 |
@@ -167,29 +167,29 @@ |
||
167 | 167 | CURLOPT_SSL_VERIFYHOST => false, |
168 | 168 | CURLOPT_HEADER => false, |
169 | 169 | CURLINFO_HEADER_OUT => true |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | |
172 | 172 | switch ($method) { |
173 | 173 | case 'POST': |
174 | - $ch->setOptions( array( |
|
174 | + $ch->setOptions(array( |
|
175 | 175 | CURLOPT_CUSTOMREQUEST => 'POST', |
176 | 176 | CURLOPT_POST => count($parameters), |
177 | 177 | CURLOPT_POSTFIELDS => $parameters |
178 | - ) ); |
|
178 | + )); |
|
179 | 179 | |
180 | - if(!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) { |
|
181 | - $ch->setOption( CURLOPT_SAFE_UPLOAD, false ); |
|
180 | + if (!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) { |
|
181 | + $ch->setOption(CURLOPT_SAFE_UPLOAD, false); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | break; |
185 | 185 | case 'DELETE': |
186 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "DELETE" ); |
|
186 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
187 | 187 | break; |
188 | 188 | case 'PATCH': |
189 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "PATCH" ); |
|
189 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "PATCH"); |
|
190 | 190 | break; |
191 | 191 | default: |
192 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "GET" ); |
|
192 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "GET"); |
|
193 | 193 | break; |
194 | 194 | } |
195 | 195 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 Dirk Groenen |
|
4 | - * |
|
5 | - * (c) Dirk Groenen <[email protected]> |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Copyright 2015 Dirk Groenen |
|
4 | + * |
|
5 | + * (c) Dirk Groenen <[email protected]> |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace DirkGroenen\Pinterest\Endpoints; |
12 | 12 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 Dirk Groenen |
|
4 | - * |
|
5 | - * (c) Dirk Groenen <[email protected]> |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Copyright 2015 Dirk Groenen |
|
4 | + * |
|
5 | + * (c) Dirk Groenen <[email protected]> |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace DirkGroenen\Pinterest\Endpoints; |
12 | 12 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 Dirk Groenen |
|
4 | - * |
|
5 | - * (c) Dirk Groenen <[email protected]> |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Copyright 2015 Dirk Groenen |
|
4 | + * |
|
5 | + * (c) Dirk Groenen <[email protected]> |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace DirkGroenen\Pinterest\Endpoints; |
12 | 12 |
@@ -58,8 +58,7 @@ |
||
58 | 58 | if (array_key_exists("image", $data)) { |
59 | 59 | if (class_exists("\CURLFile")) { |
60 | 60 | $data["image"] = new \CURLFile($data['image']); |
61 | - } |
|
62 | - else { |
|
61 | + } else { |
|
63 | 62 | $data["image"] = '@' . $data['image']; |
64 | 63 | } |
65 | 64 | } |