| @@ -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 |      { | 
| @@ -55,7 +55,7 @@ discard block | ||
| 55 | 55 | * @param string $client_id | 
| 56 | 56 | * @param string $client_secret | 
| 57 | 57 | */ | 
| 58 | - public function __construct( $client_id, $client_secret, $request ) | |
| 58 | + public function __construct($client_id, $client_secret, $request) | |
| 59 | 59 |      { | 
| 60 | 60 | $this->client_id = $client_id; | 
| 61 | 61 | $this->client_secret = $client_secret; | 
| @@ -75,7 +75,7 @@ discard block | ||
| 75 | 75 | * @param string $redirect_uri | 
| 76 | 76 | * @return string | 
| 77 | 77 | */ | 
| 78 | -    public function getLoginUrl( $redirect_uri, $scopes = array("read_public"), $response_type = "code" ) | |
| 78 | +    public function getLoginUrl($redirect_uri, $scopes = array("read_public"), $response_type = "code") | |
| 79 | 79 |      { | 
| 80 | 80 | $queryparams = array( | 
| 81 | 81 | "response_type" => $response_type, | 
| @@ -87,7 +87,7 @@ discard block | ||
| 87 | 87 | ); | 
| 88 | 88 | |
| 89 | 89 | // Build url and return it | 
| 90 | - return sprintf( "%s?%s", self::AUTH_HOST, http_build_query($queryparams) ); | |
| 90 | +        return sprintf("%s?%s", self::AUTH_HOST, http_build_query($queryparams)); | |
| 91 | 91 | } | 
| 92 | 92 | |
| 93 | 93 | /** | 
| @@ -98,7 +98,7 @@ discard block | ||
| 98 | 98 | */ | 
| 99 | 99 | private function generateState() | 
| 100 | 100 |      { | 
| 101 | - return substr( md5( rand() ), 0, 7 ); | |
| 101 | + return substr(md5(rand()), 0, 7); | |
| 102 | 102 | } | 
| 103 | 103 | |
| 104 | 104 | /** | 
| @@ -128,7 +128,7 @@ discard block | ||
| 128 | 128 | * @param string $code | 
| 129 | 129 | * @return array | 
| 130 | 130 | */ | 
| 131 | - public function getOAuthToken( $code ) | |
| 131 | + public function getOAuthToken($code) | |
| 132 | 132 |      { | 
| 133 | 133 | // Build data array | 
| 134 | 134 | $data = array( | 
| @@ -151,7 +151,7 @@ discard block | ||
| 151 | 151 | * @param string $access_token | 
| 152 | 152 | * @return void | 
| 153 | 153 | */ | 
| 154 | - public function setOAuthToken( $access_token ) | |
| 154 | + public function setOAuthToken($access_token) | |
| 155 | 155 |      { | 
| 156 | 156 | $this->request->setAccessToken($access_token); | 
| 157 | 157 | } | 
| @@ -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 | |
| @@ -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 |      { | 
| @@ -11,7 +11,6 @@ | ||
| 11 | 11 | namespace DirkGroenen\Pinterest\Endpoints; | 
| 12 | 12 | |
| 13 | 13 | use DirkGroenen\Pinterest\Models\Board; | 
| 14 | -use DirkGroenen\Pinterest\Models\Collection; | |
| 15 | 14 | |
| 16 | 15 |  class Boards extends Endpoint { | 
| 17 | 16 | |
| @@ -24,10 +24,10 @@ discard block | ||
| 24 | 24 | * @throws Exceptions/PinterestExceptions | 
| 25 | 25 | * @return Models\Board | 
| 26 | 26 | */ | 
| 27 | - public function get( $board_id, array $data = [] ) | |
| 27 | + public function get($board_id, array $data = []) | |
| 28 | 28 |      { | 
| 29 | -        $response = $this->request->get( sprintf("boards/%s", $board_id), $data ); | |
| 30 | - return new Board( $this->master, $response ); | |
| 29 | +        $response = $this->request->get(sprintf("boards/%s", $board_id), $data); | |
| 30 | + return new Board($this->master, $response); | |
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | 33 | /** | 
| @@ -38,10 +38,10 @@ discard block | ||
| 38 | 38 | * @throws Exceptions/PinterestExceptions | 
| 39 | 39 | * @return Models\Board | 
| 40 | 40 | */ | 
| 41 | - public function create( array $data ) | |
| 41 | + public function create(array $data) | |
| 42 | 42 |      { | 
| 43 | - $response = $this->request->post( "boards", $data ); | |
| 44 | - return new Board( $this->master, $response ); | |
| 43 | +        $response = $this->request->post("boards", $data); | |
| 44 | + return new Board($this->master, $response); | |
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | 47 | /** | 
| @@ -52,9 +52,9 @@ discard block | ||
| 52 | 52 | * @throws Exceptions/PinterestExceptions | 
| 53 | 53 | * @return Models\Board | 
| 54 | 54 | */ | 
| 55 | - public function delete( $board_id ) | |
| 55 | + public function delete($board_id) | |
| 56 | 56 |      { | 
| 57 | -        $response = $this->request->delete( sprintf("boards/%s", $board_id) ); | |
| 57 | +        $response = $this->request->delete(sprintf("boards/%s", $board_id)); | |
| 58 | 58 | return true; | 
| 59 | 59 | } | 
| 60 | 60 | } | 
| 61 | 61 | \ No newline at end of file | 
| @@ -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\Exceptions; | 
| 12 | 12 | |
| @@ -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 | */ | 
| @@ -37,7 +37,7 @@ | ||
| 37 | 37 | * @param Pinterest $master | 
| 38 | 38 | * @return void | 
| 39 | 39 | */ | 
| 40 | - public function __construct( Request $request, Pinterest $master ) | |
| 40 | + public function __construct(Request $request, Pinterest $master) | |
| 41 | 41 |      { | 
| 42 | 42 | $this->request = $request; | 
| 43 | 43 | $this->master = $master; | 
| @@ -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\Exceptions; | 
| 12 | 12 | |
| @@ -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 |      { | 
| @@ -24,10 +24,10 @@ discard block | ||
| 24 | 24 | * @throws Exceptions/PinterestExceptions | 
| 25 | 25 | * @return Models\Pin | 
| 26 | 26 | */ | 
| 27 | - public function get( $pin_id, array $data = [] ) | |
| 27 | + public function get($pin_id, array $data = []) | |
| 28 | 28 |      { | 
| 29 | -        $response = $this->request->get( sprintf("pins/%s", $pin_id), $data ); | |
| 30 | - return new Pin( $this->master, $response ); | |
| 29 | +        $response = $this->request->get(sprintf("pins/%s", $pin_id), $data); | |
| 30 | + return new Pin($this->master, $response); | |
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | 33 | /** | 
| @@ -39,10 +39,10 @@ discard block | ||
| 39 | 39 | * @throws Exceptions/PinterestExceptions | 
| 40 | 40 | * @return Models\Collection | 
| 41 | 41 | */ | 
| 42 | - public function fromBoard( $board_id, array $data = [] ) | |
| 42 | + public function fromBoard($board_id, array $data = []) | |
| 43 | 43 |      { | 
| 44 | -        $response = $this->request->get( sprintf("boards/%s/pins", $board_id), $data ); | |
| 45 | - return new Collection( $this->master, $response, "Pin" ); | |
| 44 | +        $response = $this->request->get(sprintf("boards/%s/pins", $board_id), $data); | |
| 45 | + return new Collection($this->master, $response, "Pin"); | |
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | 48 | /** | 
| @@ -53,19 +53,19 @@ discard block | ||
| 53 | 53 | * @throws Exceptions/PinterestExceptions | 
| 54 | 54 | * @return Models\Pin | 
| 55 | 55 | */ | 
| 56 | - public function create( array $data ) | |
| 56 | + public function create(array $data) | |
| 57 | 57 |      { | 
| 58 | -        if( array_key_exists("image", $data) ){ | |
| 59 | -            if(class_exists("\CURLFile")){ | |
| 58 | +        if (array_key_exists("image", $data)) { | |
| 59 | +            if (class_exists("\CURLFile")) { | |
| 60 | 60 | $data["image"] = new \CURLFile($data['image']); | 
| 61 | 61 | } | 
| 62 | -            else{ | |
| 62 | +            else { | |
| 63 | 63 | $data["image"] = '@' . $data['image']; | 
| 64 | 64 | } | 
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | - $response = $this->request->post( "pins", $data ); | |
| 68 | - return new Pin( $this->master, $response ); | |
| 67 | +        $response = $this->request->post("pins", $data); | |
| 68 | + return new Pin($this->master, $response); | |
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | 71 | /** | 
| @@ -77,10 +77,10 @@ discard block | ||
| 77 | 77 | * @throws Exceptions/PinterestExceptions | 
| 78 | 78 | * @return Models\Pin | 
| 79 | 79 | */ | 
| 80 | - public function update( $pin_id, array $data ) | |
| 80 | + public function update($pin_id, array $data) | |
| 81 | 81 |      { | 
| 82 | -        $response = $this->request->update( sprintf("pins/%s", $pin_id), $data ); | |
| 83 | - return new Pin( $this->master, $response ); | |
| 82 | +        $response = $this->request->update(sprintf("pins/%s", $pin_id), $data); | |
| 83 | + return new Pin($this->master, $response); | |
| 84 | 84 | } | 
| 85 | 85 | |
| 86 | 86 | /** | 
| @@ -91,9 +91,9 @@ discard block | ||
| 91 | 91 | * @throws Exceptions/PinterestExceptions | 
| 92 | 92 | * @return boolean | 
| 93 | 93 | */ | 
| 94 | - public function delete( $pin_id ) | |
| 94 | + public function delete($pin_id) | |
| 95 | 95 |      { | 
| 96 | -        $response = $this->request->delete( sprintf("pins/%s", $pin_id) ); | |
| 96 | +        $response = $this->request->delete(sprintf("pins/%s", $pin_id)); | |
| 97 | 97 | return true; | 
| 98 | 98 | } | 
| 99 | 99 | } | 
| 100 | 100 | \ No newline at end of file | 
| @@ -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); | 
| @@ -61,25 +61,25 @@ discard block | ||
| 61 | 61 | * @param string $model | 
| 62 | 62 | * @throws InvalidModelException | 
| 63 | 63 | */ | 
| 64 | -    public function __construct( Pinterest $master, $items, $model ){ | |
| 64 | +    public function __construct(Pinterest $master, $items, $model) { | |
| 65 | 65 | $this->master = $master; | 
| 66 | 66 | |
| 67 | 67 | // Create class path | 
| 68 | - $this->model = ucfirst( strtolower($model) ); | |
| 68 | + $this->model = ucfirst(strtolower($model)); | |
| 69 | 69 | |
| 70 | -        if(!class_exists("\\DirkGroenen\\Pinterest\\Models\\" . $this->model)) | |
| 70 | +        if (!class_exists("\\DirkGroenen\\Pinterest\\Models\\" . $this->model)) | |
| 71 | 71 | throw new InvalidModelException; | 
| 72 | 72 | |
| 73 | 73 | // Get items and response instance | 
| 74 | -        if( is_array($items) ){ | |
| 74 | +        if (is_array($items)) { | |
| 75 | 75 | $this->response = null; | 
| 76 | 76 | $this->items = $items; | 
| 77 | 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 | 81 | } | 
| 82 | -        else{ | |
| 82 | +        else { | |
| 83 | 83 |             throw new PinterestException("$items needs to be an instance of Transport\Response or an array."); | 
| 84 | 84 | } | 
| 85 | 85 | |
| @@ -87,10 +87,10 @@ discard block | ||
| 87 | 87 | $this->items = $this->buildCollectionModels($this->items); | 
| 88 | 88 | |
| 89 | 89 | // Add pagination object | 
| 90 | -        if( isset($this->response->page) && !empty($this->response->page['next']) ){ | |
| 90 | +        if (isset($this->response->page) && !empty($this->response->page['next'])) { | |
| 91 | 91 | $this->pagination = $this->response->page; | 
| 92 | 92 | } | 
| 93 | -        else{ | |
| 93 | +        else { | |
| 94 | 94 | $this->pagination = false; | 
| 95 | 95 | } | 
| 96 | 96 | } | 
| @@ -117,9 +117,9 @@ discard block | ||
| 117 | 117 |      { | 
| 118 | 118 | $modelcollection = []; | 
| 119 | 119 | |
| 120 | -        foreach($items as $item){ | |
| 120 | +        foreach ($items as $item) { | |
| 121 | 121 |              $class = new \ReflectionClass("\\DirkGroenen\\Pinterest\\Models\\" . $this->model); | 
| 122 | - $modelcollection[] = $class->newInstanceArgs( [$this->master, $item] ); | |
| 122 | + $modelcollection[] = $class->newInstanceArgs([$this->master, $item]); | |
| 123 | 123 | } | 
| 124 | 124 | |
| 125 | 125 | return $modelcollection; | 
| @@ -133,7 +133,7 @@ discard block | ||
| 133 | 133 | */ | 
| 134 | 134 | public function hasNextPage() | 
| 135 | 135 |      { | 
| 136 | - return ($this->response != null && isset($this->response->page['next']) ); | |
| 136 | + return ($this->response != null && isset($this->response->page['next'])); | |
| 137 | 137 | } | 
| 138 | 138 | |
| 139 | 139 | /** | 
| @@ -143,7 +143,7 @@ discard block | ||
| 143 | 143 | * @param int $index | 
| 144 | 144 | * @return Model | 
| 145 | 145 | */ | 
| 146 | - public function get( $index ) | |
| 146 | + public function get($index) | |
| 147 | 147 |      { | 
| 148 | 148 | return $this->items[$index]; | 
| 149 | 149 | } | 
| @@ -158,7 +158,7 @@ discard block | ||
| 158 | 158 |      { | 
| 159 | 159 | $items = []; | 
| 160 | 160 | |
| 161 | -        foreach($this->items as $item){ | |
| 161 | +        foreach ($this->items as $item) { | |
| 162 | 162 | $items[] = $item->toArray(); | 
| 163 | 163 | } | 
| 164 | 164 | |
| @@ -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 | } | 
| @@ -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 | 
| @@ -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,11 +55,11 @@ discard block | ||
| 55 | 55 | */ | 
| 56 | 56 | public function __construct($client_id, $client_secret, $curlbuilder = null) | 
| 57 | 57 |      { | 
| 58 | - if($curlbuilder == null) | |
| 58 | + if ($curlbuilder == null) | |
| 59 | 59 | $curlbuilder = new CurlBuilder(); | 
| 60 | 60 | |
| 61 | 61 | // Create new instance of Transport\Request | 
| 62 | - $this->request = new Request( $curlbuilder ); | |
| 62 | + $this->request = new Request($curlbuilder); | |
| 63 | 63 | |
| 64 | 64 | // Create and set new instance of the OAuth class | 
| 65 | 65 | $this->auth = new PinterestOAuth($client_id, $client_secret, $this->request); | 
| @@ -79,15 +79,15 @@ discard block | ||
| 79 | 79 | $class = "\\DirkGroenen\\Pinterest\\Endpoints\\" . ucfirst($endpoint); | 
| 80 | 80 | |
| 81 | 81 | // Check if an instance has already been initiated | 
| 82 | -        if(!isset($this->cachedEndpoints[$endpoint])){ | |
| 82 | +        if (!isset($this->cachedEndpoints[$endpoint])) { | |
| 83 | 83 | // Check endpoint existence | 
| 84 | - if(!class_exists($class)) | |
| 84 | + if (!class_exists($class)) | |
| 85 | 85 | throw new InvalidEndpointException; | 
| 86 | 86 | |
| 87 | 87 | // Create a reflection of the called class and initialize it | 
| 88 | 88 | // with a reference to the request class | 
| 89 | 89 | $ref = new \ReflectionClass($class); | 
| 90 | - $obj = $ref->newInstanceArgs([ $this->request, $this ]); | |
| 90 | + $obj = $ref->newInstanceArgs([$this->request, $this]); | |
| 91 | 91 | |
| 92 | 92 | $this->cachedEndpoints[$endpoint] = $obj; | 
| 93 | 93 | } | 
| @@ -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 |      { | 
| @@ -49,7 +49,7 @@ discard block | ||
| 49 | 49 | * | 
| 50 | 50 | * @param CurlBuilder $curlbuilder | 
| 51 | 51 | */ | 
| 52 | - public function __construct( CurlBuilder $curlbuilder ) | |
| 52 | + public function __construct(CurlBuilder $curlbuilder) | |
| 53 | 53 |      { | 
| 54 | 54 | $this->curlbuilder = $curlbuilder; | 
| 55 | 55 | } | 
| @@ -60,7 +60,7 @@ discard block | ||
| 60 | 60 | * @access public | 
| 61 | 61 | * @param string $token | 
| 62 | 62 | */ | 
| 63 | - public function setAccessToken( $token ) | |
| 63 | + public function setAccessToken($token) | |
| 64 | 64 |      { | 
| 65 | 65 | $this->access_token = $token; | 
| 66 | 66 | } | 
| @@ -73,9 +73,9 @@ discard block | ||
| 73 | 73 | * @param array $parameters | 
| 74 | 74 | * @return [type] | 
| 75 | 75 | */ | 
| 76 | - public function get( $endpoint, array $parameters = array() ) | |
| 76 | + public function get($endpoint, array $parameters = array()) | |
| 77 | 77 |      { | 
| 78 | -        if(!empty($parameters)) { | |
| 78 | +        if (!empty($parameters)) { | |
| 79 | 79 |              $path = sprintf("%s/?%s", $endpoint, http_build_query($parameters)); | 
| 80 | 80 | } | 
| 81 | 81 |          else { | 
| @@ -93,9 +93,9 @@ discard block | ||
| 93 | 93 | * @param array $parameters | 
| 94 | 94 | * @return [type] | 
| 95 | 95 | */ | 
| 96 | - public function post( $path, array $parameters = array() ) | |
| 96 | + public function post($path, array $parameters = array()) | |
| 97 | 97 |      { | 
| 98 | -        return $this->execute("POST", sprintf("%s%s", $this->host, $path), $parameters ); | |
| 98 | +        return $this->execute("POST", sprintf("%s%s", $this->host, $path), $parameters); | |
| 99 | 99 | } | 
| 100 | 100 | |
| 101 | 101 | /** | 
| @@ -106,9 +106,9 @@ discard block | ||
| 106 | 106 | * @param array $parameters | 
| 107 | 107 | * @return [type] | 
| 108 | 108 | */ | 
| 109 | - public function delete( $path, array $parameters = array() ) | |
| 109 | + public function delete($path, array $parameters = array()) | |
| 110 | 110 |      { | 
| 111 | -        return $this->execute("DELETE", sprintf("%s%s", $this->host, $path) . "/", $parameters ); | |
| 111 | +        return $this->execute("DELETE", sprintf("%s%s", $this->host, $path) . "/", $parameters); | |
| 112 | 112 | } | 
| 113 | 113 | |
| 114 | 114 | /** | 
| @@ -119,9 +119,9 @@ discard block | ||
| 119 | 119 | * @param array $parameters | 
| 120 | 120 | * @return [type] | 
| 121 | 121 | */ | 
| 122 | - public function update( $path, array $parameters = array() ) | |
| 122 | + public function update($path, array $parameters = array()) | |
| 123 | 123 |      { | 
| 124 | -        return $this->execute("PATCH", sprintf("%s%s", $this->host, $path) . "/", $parameters ); | |
| 124 | +        return $this->execute("PATCH", sprintf("%s%s", $this->host, $path) . "/", $parameters); | |
| 125 | 125 | } | 
| 126 | 126 | |
| 127 | 127 | /** | 
| @@ -146,10 +146,10 @@ discard block | ||
| 146 | 146 | * @param array $headers | 
| 147 | 147 | * @return mixed | 
| 148 | 148 | */ | 
| 149 | - public function execute( $method, $apiCall, array $parameters = array(), $headers = array() ) | |
| 149 | + public function execute($method, $apiCall, array $parameters = array(), $headers = array()) | |
| 150 | 150 |      { | 
| 151 | 151 | // Check if the access token needs to be added | 
| 152 | -        if($this->access_token != null){ | |
| 152 | +        if ($this->access_token != null) { | |
| 153 | 153 | $headers = array_merge($headers, array( | 
| 154 | 154 | "Authorization: Bearer " . $this->access_token, | 
| 155 | 155 | "Content-ype: multipart/form-data", | 
| @@ -160,7 +160,7 @@ discard block | ||
| 160 | 160 | $ch = $this->curlbuilder->create(); | 
| 161 | 161 | |
| 162 | 162 | // Set default options | 
| 163 | - $ch->setOptions( array( | |
| 163 | + $ch->setOptions(array( | |
| 164 | 164 | CURLOPT_URL => $apiCall, | 
| 165 | 165 | CURLOPT_HTTPHEADER => $headers, | 
| 166 | 166 | CURLOPT_CONNECTTIMEOUT => 20, | 
| @@ -170,28 +170,28 @@ discard block | ||
| 170 | 170 | CURLOPT_SSL_VERIFYHOST => false, | 
| 171 | 171 | CURLOPT_HEADER => false, | 
| 172 | 172 | CURLINFO_HEADER_OUT => true | 
| 173 | - ) ); | |
| 173 | + )); | |
| 174 | 174 | |
| 175 | 175 |          switch ($method) { | 
| 176 | 176 | case 'POST': | 
| 177 | - $ch->setOptions( array( | |
| 177 | + $ch->setOptions(array( | |
| 178 | 178 | CURLOPT_CUSTOMREQUEST => 'POST', | 
| 179 | 179 | CURLOPT_POST => count($parameters), | 
| 180 | 180 | CURLOPT_POSTFIELDS => $parameters | 
| 181 | - ) ); | |
| 181 | + )); | |
| 182 | 182 | |
| 183 | -                if(!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) | |
| 184 | - $ch->setOption( CURLOPT_SAFE_UPLOAD, false ); | |
| 183 | +                if (!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) | |
| 184 | + $ch->setOption(CURLOPT_SAFE_UPLOAD, false); | |
| 185 | 185 | |
| 186 | 186 | break; | 
| 187 | 187 | case 'DELETE': | 
| 188 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "DELETE" ); | |
| 188 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "DELETE"); | |
| 189 | 189 | break; | 
| 190 | 190 | case 'PATCH': | 
| 191 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "PATCH" ); | |
| 191 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "PATCH"); | |
| 192 | 192 | break; | 
| 193 | 193 | default: | 
| 194 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "GET" ); | |
| 194 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "GET"); | |
| 195 | 195 | break; | 
| 196 | 196 | } | 
| 197 | 197 | |
| @@ -200,16 +200,16 @@ discard block | ||
| 200 | 200 | $response_data = $ch->execute(); | 
| 201 | 201 | |
| 202 | 202 | // Check if we have a valid response | 
| 203 | -        if ( !$response_data || $ch->hasErrors() ) { | |
| 204 | - throw new PinterestException( 'Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber() ); | |
| 203 | +        if (!$response_data || $ch->hasErrors()) { | |
| 204 | +            throw new PinterestException('Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber()); | |
| 205 | 205 | } | 
| 206 | 206 | |
| 207 | 207 | // Initiate the response | 
| 208 | 208 | $response = new Response($response_data, $ch); | 
| 209 | 209 | |
| 210 | 210 | // Check the response code | 
| 211 | -        if ( $response->getResponseCode() >= 400 ) { | |
| 212 | - throw new PinterestException( 'Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->message, $response->getResponseCode() ); | |
| 211 | +        if ($response->getResponseCode() >= 400) { | |
| 212 | +            throw new PinterestException('Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->message, $response->getResponseCode()); | |
| 213 | 213 | } | 
| 214 | 214 | $this->headers = $ch->getHeaders(); | 
| 215 | 215 | |
| @@ -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 |      { | 
| @@ -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 | |
| @@ -36,12 +36,12 @@ discard block | ||
| 36 | 36 | * @param CurlBuilder $curl | 
| 37 | 37 | * @param curl $curl | 
| 38 | 38 | */ | 
| 39 | - public function __construct( $response, CurlBuilder $curl ) | |
| 39 | + public function __construct($response, CurlBuilder $curl) | |
| 40 | 40 |      { | 
| 41 | 41 | $this->response = $response; | 
| 42 | 42 | $this->curl = $curl; | 
| 43 | 43 | |
| 44 | -        if( is_string($response) ){ | |
| 44 | +        if (is_string($response)) { | |
| 45 | 45 | $this->response = $this->decodeString($response); | 
| 46 | 46 | } | 
| 47 | 47 | } | 
| @@ -53,7 +53,7 @@ discard block | ||
| 53 | 53 | * @param string $response | 
| 54 | 54 | * @return array | 
| 55 | 55 | */ | 
| 56 | - private function decodeString( $response ) | |
| 56 | + private function decodeString($response) | |
| 57 | 57 |      { | 
| 58 | 58 | return json_decode($response, true); | 
| 59 | 59 | } | 
| @@ -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; | 
| @@ -10,8 +10,6 @@ | ||
| 10 | 10 | |
| 11 | 11 | namespace DirkGroenen\Pinterest\Utils; | 
| 12 | 12 | |
| 13 | -use DirkGroenen\Pinterest\Exceptions\PinterestException; | |
| 14 | - | |
| 15 | 13 |  class CurlBuilder { | 
| 16 | 14 | |
| 17 | 15 | /** | 
| @@ -55,9 +55,9 @@ discard block | ||
| 55 | 55 | * @param string $value | 
| 56 | 56 | * @return $this | 
| 57 | 57 | */ | 
| 58 | - public function setOption( $option, $value ) | |
| 58 | + public function setOption($option, $value) | |
| 59 | 59 |      { | 
| 60 | - curl_setopt($this->curl, $option, $value ); | |
| 60 | + curl_setopt($this->curl, $option, $value); | |
| 61 | 61 | |
| 62 | 62 | return $this; | 
| 63 | 63 | } | 
| @@ -69,7 +69,7 @@ discard block | ||
| 69 | 69 | * @param array $options | 
| 70 | 70 | * @return $this | 
| 71 | 71 | */ | 
| 72 | - public function setOptions( array $options = [] ) | |
| 72 | + public function setOptions(array $options = []) | |
| 73 | 73 |      { | 
| 74 | 74 | curl_setopt_array($this->curl, $options); | 
| 75 | 75 | |
| @@ -163,7 +163,7 @@ discard block | ||
| 163 | 163 | */ | 
| 164 | 164 |      private function parseHeaders($headers) { | 
| 165 | 165 | $result = array(); | 
| 166 | -        foreach(explode("\n", $headers) as $row){ | |
| 166 | +        foreach (explode("\n", $headers) as $row) { | |
| 167 | 167 |              $header = explode(':', $row, 2); | 
| 168 | 168 | if (count($header) == 2) | 
| 169 | 169 | $result[$header[0]] = trim($header[1]); | 
| @@ -186,14 +186,14 @@ discard block | ||
| 186 | 186 | $mr = 5; | 
| 187 | 187 | $body = null; | 
| 188 | 188 | |
| 189 | -        if(ini_get("open_basedir") == "" && ini_get("safe_mode" == "Off")){ | |
| 189 | +        if (ini_get("open_basedir") == "" && ini_get("safe_mode" == "Off")) { | |
| 190 | 190 | curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, $mr > 0); | 
| 191 | 191 | curl_setopt($this->curl, CURLOPT_MAXREDIRS, $mr); | 
| 192 | 192 | } | 
| 193 | -        else{ | |
| 193 | +        else { | |
| 194 | 194 | $this->setOption(CURLOPT_FOLLOWLOCATION, false); | 
| 195 | 195 | |
| 196 | -            if($mr > 0){ | |
| 196 | +            if ($mr > 0) { | |
| 197 | 197 | $original_url = $this->getInfo(CURLINFO_EFFECTIVE_URL); | 
| 198 | 198 | $newurl = $original_url; | 
| 199 | 199 | |
| @@ -203,7 +203,7 @@ discard block | ||
| 203 | 203 | //curl_setopt($rch, CURLOPT_NOBODY, true); | 
| 204 | 204 | curl_setopt($rch, CURLOPT_FORBID_REUSE, false); | 
| 205 | 205 | |
| 206 | -                do{ | |
| 206 | +                do { | |
| 207 | 207 | curl_setopt($rch, CURLOPT_URL, $newurl); | 
| 208 | 208 | $response = curl_exec($rch); | 
| 209 | 209 | |
| @@ -211,29 +211,29 @@ discard block | ||
| 211 | 211 | $header = substr($response, 0, $header_size); | 
| 212 | 212 | $body = substr($response, $header_size); | 
| 213 | 213 | |
| 214 | -                    if(curl_errno($rch)){ | |
| 214 | +                    if (curl_errno($rch)) { | |
| 215 | 215 | $code = 0; | 
| 216 | 216 | } | 
| 217 | -                    else{ | |
| 217 | +                    else { | |
| 218 | 218 | $code = curl_getinfo($rch, CURLINFO_HTTP_CODE); | 
| 219 | 219 | |
| 220 | 220 |                          if ($code == 301 || $code == 302) { | 
| 221 | 221 |                              preg_match('/Location:(.*?)\n/i', $header, $matches); | 
| 222 | 222 | $newurl = trim(array_pop($matches)); | 
| 223 | 223 | } | 
| 224 | -                        else{ | |
| 224 | +                        else { | |
| 225 | 225 | $code = 0; | 
| 226 | 226 | } | 
| 227 | 227 | } | 
| 228 | - } while($code && --$mr); | |
| 228 | + } while ($code && --$mr); | |
| 229 | 229 | |
| 230 | 230 | curl_close($rch); | 
| 231 | 231 | |
| 232 | -                if(!$mr){ | |
| 233 | -                    if ($maxredirect === null){ | |
| 232 | +                if (!$mr) { | |
| 233 | +                    if ($maxredirect === null) { | |
| 234 | 234 |                          trigger_error('Too many redirects.', E_USER_WARNING); | 
| 235 | 235 | } | 
| 236 | -                    else{ | |
| 236 | +                    else { | |
| 237 | 237 | $maxredirect = 0; | 
| 238 | 238 | } | 
| 239 | 239 | |
| @@ -245,7 +245,7 @@ discard block | ||
| 245 | 245 | } | 
| 246 | 246 | } | 
| 247 | 247 | |
| 248 | -        if (!$body){ | |
| 248 | +        if (!$body) { | |
| 249 | 249 | curl_setopt($this->curl, CURLOPT_HEADER, true); | 
| 250 | 250 | $response = curl_exec($this->curl); | 
| 251 | 251 | |
| @@ -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 | |
| @@ -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 | |