| @@ -92,6 +92,7 @@ | ||
| 92 | 92 | * Builds the request URL to the PeopleMatter API for a specified action | 
| 93 | 93 | * @param string $action The long URL | 
| 94 | 94 | * @param string $action The API action | 
| 95 | + * @param string $url | |
| 95 | 96 | * @return string The URL | 
| 96 | 97 | */ | 
| 97 | 98 |      protected function buildRequestUrl($url,$action = "shorten"){ | 
| @@ -20,7 +20,7 @@ discard block | ||
| 20 | 20 | * @param string $host The Host URL | 
| 21 | 21 | * @param string $client The Client instance that will handle the http request | 
| 22 | 22 | */ | 
| 23 | -    public function __construct($token, $version = self::V3, $host = "api-ssl.bitly.com", Client $client = null){ | |
| 23 | +    public function __construct($token, $version = self::V3, $host = "api-ssl.bitly.com", Client $client = null) { | |
| 24 | 24 | $this->client = $client; | 
| 25 | 25 | $this->token = $token; | 
| 26 | 26 | $this->version = $version; | 
| @@ -45,14 +45,14 @@ discard block | ||
| 45 | 45 | * @param string $raw The data from the response | 
| 46 | 46 | * @return array | 
| 47 | 47 | */ | 
| 48 | -    protected function handleResponse($raw){ | |
| 49 | - $data = json_decode($raw,true); | |
| 48 | +    protected function handleResponse($raw) { | |
| 49 | + $data = json_decode($raw, true); | |
| 50 | 50 | |
| 51 | -        if(!isset($data['status_code'])){ | |
| 51 | +        if (!isset($data['status_code'])) { | |
| 52 | 52 | return $raw; | 
| 53 | 53 | } | 
| 54 | 54 | |
| 55 | -        if($data['status_code']>=300 || $data['status_code']<200){ | |
| 55 | +        if ($data['status_code'] >= 300 || $data['status_code'] < 200) { | |
| 56 | 56 |              switch ($data['status_txt']) { | 
| 57 | 57 | case 'RATE_LIMIT_EXCEEDED': | 
| 58 | 58 | throw new BitlyRateLimitException; | 
| @@ -76,12 +76,12 @@ discard block | ||
| 76 | 76 | * @param boolean $encode Whether or not to encode the URL | 
| 77 | 77 | * @return string The corrected URL | 
| 78 | 78 | */ | 
| 79 | -    protected function fixUrl($url, $encode){ | |
| 80 | -        if(strpos($url, "http") !== 0){ | |
| 79 | +    protected function fixUrl($url, $encode) { | |
| 80 | +        if (strpos($url, "http") !== 0) { | |
| 81 | 81 | $url = "http://".$url; | 
| 82 | 82 | } | 
| 83 | 83 | |
| 84 | -        if($encode){ | |
| 84 | +        if ($encode) { | |
| 85 | 85 | $url = urlencode($url); | 
| 86 | 86 | } | 
| 87 | 87 | |
| @@ -94,7 +94,7 @@ discard block | ||
| 94 | 94 | * @param string $action The API action | 
| 95 | 95 | * @return string The URL | 
| 96 | 96 | */ | 
| 97 | -    protected function buildRequestUrl($url,$action = "shorten"){ | |
| 97 | +    protected function buildRequestUrl($url, $action = "shorten") { | |
| 98 | 98 |          return "https://{$this->host}/{$this->version}/{$action}?access_token={$this->token}&format=json&longUrl={$url}"; | 
| 99 | 99 | } | 
| 100 | 100 | |
| @@ -102,9 +102,9 @@ discard block | ||
| 102 | 102 | * Returns the Client instance | 
| 103 | 103 | * @return Client | 
| 104 | 104 | */ | 
| 105 | -    protected function getRequest(){ | |
| 105 | +    protected function getRequest() { | |
| 106 | 106 | $client = $this->client; | 
| 107 | -        if(!$client instanceof Client){ | |
| 107 | +        if (!$client instanceof Client) { | |
| 108 | 108 | $client = new Client(); | 
| 109 | 109 | } | 
| 110 | 110 | return $client; | 
| @@ -118,7 +118,7 @@ discard block | ||
| 118 | 118 | protected function exec($url) | 
| 119 | 119 |      { | 
| 120 | 120 | $client = $this->getRequest(); | 
| 121 | -        $response = $client->request('GET',$url); | |
| 121 | +        $response = $client->request('GET', $url); | |
| 122 | 122 | return $this->handleResponse($response->getBody()); | 
| 123 | 123 | } | 
| 124 | 124 | } |