@@ -54,6 +54,7 @@ |
||
| 54 | 54 | * |
| 55 | 55 | * @param string $client_id |
| 56 | 56 | * @param string $client_secret |
| 57 | + * @param Request $request |
|
| 57 | 58 | */ |
| 58 | 59 | public function __construct( $client_id, $client_secret, $request ) |
| 59 | 60 | { |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param string $board_id |
| 23 | 23 | * @param array $data |
| 24 | 24 | * @throws Exceptions/PinterestExceptions |
| 25 | - * @return Models\Board |
|
| 25 | + * @return Board |
|
| 26 | 26 | */ |
| 27 | 27 | public function get( $board_id, array $data = [] ) |
| 28 | 28 | { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @access public |
| 37 | 37 | * @param array $data |
| 38 | 38 | * @throws Exceptions/PinterestExceptions |
| 39 | - * @return Models\Board |
|
| 39 | + * @return Board |
|
| 40 | 40 | */ |
| 41 | 41 | public function create( array $data ) |
| 42 | 42 | { |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @access public |
| 51 | 51 | * @param string $board_id |
| 52 | 52 | * @throws Exceptions/PinterestExceptions |
| 53 | - * @return Models\Board |
|
| 53 | + * @return boolean |
|
| 54 | 54 | */ |
| 55 | 55 | public function delete( $board_id ) |
| 56 | 56 | { |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | /** |
| 34 | 34 | * Create a new model instance |
| 35 | 35 | * |
| 36 | - * @param Transport\Request $request |
|
| 36 | + * @param Request $request |
|
| 37 | 37 | * @param Pinterest $master |
| 38 | 38 | * @return void |
| 39 | 39 | */ |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param string $pin_id |
| 23 | 23 | * @param array $data |
| 24 | 24 | * @throws Exceptions/PinterestExceptions |
| 25 | - * @return Models\Pin |
|
| 25 | + * @return Pin |
|
| 26 | 26 | */ |
| 27 | 27 | public function get( $pin_id, array $data = [] ) |
| 28 | 28 | { |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param string $board_id |
| 38 | 38 | * @param array $data |
| 39 | 39 | * @throws Exceptions/PinterestExceptions |
| 40 | - * @return Models\Collection |
|
| 40 | + * @return Collection |
|
| 41 | 41 | */ |
| 42 | 42 | public function fromBoard( $board_id, array $data = [] ) |
| 43 | 43 | { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @access public |
| 52 | 52 | * @param array $data |
| 53 | 53 | * @throws Exceptions/PinterestExceptions |
| 54 | - * @return Models\Pin |
|
| 54 | + * @return Pin |
|
| 55 | 55 | */ |
| 56 | 56 | public function create( array $data ) |
| 57 | 57 | { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @param string $pin_id |
| 76 | 76 | * @param array $data |
| 77 | 77 | * @throws Exceptions/PinterestExceptions |
| 78 | - * @return Models\Pin |
|
| 78 | + * @return Pin |
|
| 79 | 79 | */ |
| 80 | 80 | public function update( $pin_id, array $data ) |
| 81 | 81 | { |
@@ -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 | } |
@@ -251,7 +251,7 @@ |
||
| 251 | 251 | * Make the collection items iteratable |
| 252 | 252 | * |
| 253 | 253 | * @access public |
| 254 | - * @return ArrayIterator |
|
| 254 | + * @return \ArrayIterator |
|
| 255 | 255 | */ |
| 256 | 256 | public function getIterator() { |
| 257 | 257 | return new \ArrayIterator($this->items); |
@@ -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 | } |
@@ -51,7 +51,6 @@ |
||
| 51 | 51 | * @param string $client_id |
| 52 | 52 | * @param string $client_secret |
| 53 | 53 | * @param CurlBuilder $curlbuilder |
| 54 | - * @param string $redirect_uri |
|
| 55 | 54 | */ |
| 56 | 55 | public function __construct($client_id, $client_secret, $curlbuilder = null) |
| 57 | 56 | { |
@@ -55,8 +55,9 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function __construct($client_id, $client_secret, $curlbuilder = null) |
| 57 | 57 | { |
| 58 | - if($curlbuilder == null) |
|
| 59 | - $curlbuilder = new CurlBuilder(); |
|
| 58 | + if($curlbuilder == null) { |
|
| 59 | + $curlbuilder = new CurlBuilder(); |
|
| 60 | + } |
|
| 60 | 61 | |
| 61 | 62 | // Create new instance of Transport\Request |
| 62 | 63 | $this->request = new Request( $curlbuilder ); |
@@ -81,8 +82,9 @@ discard block |
||
| 81 | 82 | // Check if an instance has already been initiated |
| 82 | 83 | if(!isset($this->cachedEndpoints[$endpoint])){ |
| 83 | 84 | // Check endpoint existence |
| 84 | - if(!class_exists($class)) |
|
| 85 | - throw new InvalidEndpointException; |
|
| 85 | + if(!class_exists($class)) { |
|
| 86 | + throw new InvalidEndpointException; |
|
| 87 | + } |
|
| 86 | 88 | |
| 87 | 89 | // Create a reflection of the called class and initialize it |
| 88 | 90 | // with a reference to the request class |
@@ -89,7 +89,6 @@ discard block |
||
| 89 | 89 | * Make a post request to the given endpoint |
| 90 | 90 | * |
| 91 | 91 | * @access public |
| 92 | - * @param string $endpoint |
|
| 93 | 92 | * @param array $parameters |
| 94 | 93 | * @return [type] |
| 95 | 94 | */ |
@@ -102,7 +101,6 @@ discard block |
||
| 102 | 101 | * Make a delete request to the given endpoint |
| 103 | 102 | * |
| 104 | 103 | * @access public |
| 105 | - * @param string $endpoint |
|
| 106 | 104 | * @param array $parameters |
| 107 | 105 | * @return [type] |
| 108 | 106 | */ |
@@ -115,7 +113,6 @@ discard block |
||
| 115 | 113 | * Make an update request to the given endpoint |
| 116 | 114 | * |
| 117 | 115 | * @access public |
| 118 | - * @param string $endpoint |
|
| 119 | 116 | * @param array $parameters |
| 120 | 117 | * @return [type] |
| 121 | 118 | */ |
@@ -127,9 +124,7 @@ discard block |
||
| 127 | 124 | /** |
| 128 | 125 | * Create a new model instance |
| 129 | 126 | * |
| 130 | - * @param Transport\Request $request |
|
| 131 | - * @param Pinterest $master |
|
| 132 | - * @return void |
|
| 127 | + * @return CurlBuilder |
|
| 133 | 128 | */ |
| 134 | 129 | public function getHeaders() |
| 135 | 130 | { |
@@ -144,7 +139,7 @@ discard block |
||
| 144 | 139 | * @param string $apiCall |
| 145 | 140 | * @param array $parameters |
| 146 | 141 | * @param array $headers |
| 147 | - * @return mixed |
|
| 142 | + * @return Response |
|
| 148 | 143 | */ |
| 149 | 144 | public function execute( $method, $apiCall, array $parameters = array(), $headers = array() ) |
| 150 | 145 | { |
@@ -77,8 +77,7 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | if(!empty($parameters)) { |
| 79 | 79 | $path = sprintf("%s/?%s", $endpoint, http_build_query($parameters)); |
| 80 | - } |
|
| 81 | - else { |
|
| 80 | + } else { |
|
| 82 | 81 | $path = $endpoint; |
| 83 | 82 | } |
| 84 | 83 | |
@@ -180,8 +179,9 @@ discard block |
||
| 180 | 179 | CURLOPT_POSTFIELDS => $parameters |
| 181 | 180 | ) ); |
| 182 | 181 | |
| 183 | - if(!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) |
|
| 184 | - $ch->setOption( CURLOPT_SAFE_UPLOAD, false ); |
|
| 182 | + if(!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) { |
|
| 183 | + $ch->setOption( CURLOPT_SAFE_UPLOAD, false ); |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | 186 | break; |
| 187 | 187 | case 'DELETE': |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * Constructor |
| 34 | 34 | * |
| 35 | - * @param array $response |
|
| 35 | + * @param string $response |
|
| 36 | 36 | * @param CurlBuilder $curl |
| 37 | 37 | * @param curl $curl |
| 38 | 38 | */ |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @access public |
| 77 | 77 | * @param string $key |
| 78 | - * @return array |
|
| 78 | + * @return boolean |
|
| 79 | 79 | */ |
| 80 | 80 | public function __isset($key) |
| 81 | 81 | { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * Execute the curl request |
| 81 | 81 | * |
| 82 | 82 | * @access public |
| 83 | - * @return mixed |
|
| 83 | + * @return false|string |
|
| 84 | 84 | */ |
| 85 | 85 | public function execute() |
| 86 | 86 | { |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * Check if the curl request ended up with errors |
| 92 | 92 | * |
| 93 | 93 | * @access public |
| 94 | - * @return boolean |
|
| 94 | + * @return integer |
|
| 95 | 95 | */ |
| 96 | 96 | public function hasErrors() |
| 97 | 97 | { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * Parse string headers into array |
| 159 | 159 | * |
| 160 | 160 | * @access private |
| 161 | - * @param array $headers |
|
| 161 | + * @param string $headers |
|
| 162 | 162 | * @return array |
| 163 | 163 | */ |
| 164 | 164 | private function parseHeaders($headers) { |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @see http://slopjong.de/2012/03/31/curl-follow-locations-with-safe_mode-enabled-or-open_basedir-set/ |
| 182 | 182 | * @access private |
| 183 | - * @return mixed |
|
| 183 | + * @return false|string |
|
| 184 | 184 | */ |
| 185 | 185 | private function execFollow() { |
| 186 | 186 | $mr = 5; |
@@ -165,10 +165,11 @@ discard block |
||
| 165 | 165 | $result = array(); |
| 166 | 166 | foreach(explode("\n", $headers) as $row){ |
| 167 | 167 | $header = explode(':', $row, 2); |
| 168 | - if (count($header) == 2) |
|
| 169 | - $result[$header[0]] = trim($header[1]); |
|
| 170 | - else |
|
| 171 | - $result[] = $header[0]; |
|
| 168 | + if (count($header) == 2) { |
|
| 169 | + $result[$header[0]] = trim($header[1]); |
|
| 170 | + } else { |
|
| 171 | + $result[] = $header[0]; |
|
| 172 | + } |
|
| 172 | 173 | } |
| 173 | 174 | return $result; |
| 174 | 175 | } |
@@ -189,8 +190,7 @@ discard block |
||
| 189 | 190 | if(ini_get("open_basedir") == "" && ini_get("safe_mode" == "Off")){ |
| 190 | 191 | curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, $mr > 0); |
| 191 | 192 | curl_setopt($this->curl, CURLOPT_MAXREDIRS, $mr); |
| 192 | - } |
|
| 193 | - else{ |
|
| 193 | + } else{ |
|
| 194 | 194 | $this->setOption(CURLOPT_FOLLOWLOCATION, false); |
| 195 | 195 | |
| 196 | 196 | if($mr > 0){ |
@@ -213,15 +213,13 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | if(curl_errno($rch)){ |
| 215 | 215 | $code = 0; |
| 216 | - } |
|
| 217 | - else{ |
|
| 216 | + } else{ |
|
| 218 | 217 | $code = curl_getinfo($rch, CURLINFO_HTTP_CODE); |
| 219 | 218 | |
| 220 | 219 | if ($code == 301 || $code == 302) { |
| 221 | 220 | preg_match('/Location:(.*?)\n/i', $header, $matches); |
| 222 | 221 | $newurl = trim(array_pop($matches)); |
| 223 | - } |
|
| 224 | - else{ |
|
| 222 | + } else{ |
|
| 225 | 223 | $code = 0; |
| 226 | 224 | } |
| 227 | 225 | } |
@@ -232,8 +230,7 @@ discard block |
||
| 232 | 230 | if(!$mr){ |
| 233 | 231 | if ($maxredirect === null){ |
| 234 | 232 | trigger_error('Too many redirects.', E_USER_WARNING); |
| 235 | - } |
|
| 236 | - else{ |
|
| 233 | + } else{ |
|
| 237 | 234 | $maxredirect = 0; |
| 238 | 235 | } |
| 239 | 236 | |