@@ -28,7 +28,7 @@ discard block  | 
                                                    ||
| 28 | 28 | |
| 29 | 29 | private $config;  | 
                                                        
| 30 | 30 | |
| 31 | - public function __construct (array $config)  | 
                                                        |
| 31 | + public function __construct(array $config)  | 
                                                        |
| 32 | 32 |        { | 
                                                        
| 33 | 33 | $this->config = $config;  | 
                                                        
| 34 | 34 | }  | 
                                                        
@@ -38,7 +38,7 @@ discard block  | 
                                                    ||
| 38 | 38 | Whatever option you need to setup the cache type, must be passed as array to constructor.  | 
                                                        
| 39 | 39 | https://www.doctrine-project.org/projects/doctrine-cache/en/1.8/index.html  | 
                                                        
| 40 | 40 | */  | 
                                                        
| 41 | - public function getCache ()  | 
                                                        |
| 41 | + public function getCache()  | 
                                                        |
| 42 | 42 |        { | 
                                                        
| 43 | 43 |               switch ($this->config['type']) { | 
                                                        
| 44 | 44 | case 'apc':  | 
                                                        
@@ -26,21 +26,21 @@ discard block  | 
                                                    ||
| 26 | 26 | |
| 27 | 27 |  class Cache { | 
                                                        
| 28 | 28 | |
| 29 | - private $config;  | 
                                                        |
| 29 | + private $config;  | 
                                                        |
| 30 | 30 | |
| 31 | - public function __construct (array $config)  | 
                                                        |
| 32 | -      { | 
                                                        |
| 33 | - $this->config = $config;  | 
                                                        |
| 34 | - }  | 
                                                        |
| 31 | + public function __construct (array $config)  | 
                                                        |
| 32 | +       { | 
                                                        |
| 33 | + $this->config = $config;  | 
                                                        |
| 34 | + }  | 
                                                        |
| 35 | 35 | |
| 36 | - /*  | 
                                                        |
| 36 | + /*  | 
                                                        |
| 37 | 37 | This class uses Doctrine Cache. You can look at its doc to add more cache type.  | 
                                                        
| 38 | 38 | Whatever option you need to setup the cache type, must be passed as array to constructor.  | 
                                                        
| 39 | 39 | https://www.doctrine-project.org/projects/doctrine-cache/en/1.8/index.html  | 
                                                        
| 40 | 40 | */  | 
                                                        
| 41 | - public function getCache ()  | 
                                                        |
| 42 | -      { | 
                                                        |
| 43 | -             switch ($this->config['type']) { | 
                                                        |
| 41 | + public function getCache ()  | 
                                                        |
| 42 | +       { | 
                                                        |
| 43 | +              switch ($this->config['type']) { | 
                                                        |
| 44 | 44 | case 'apc':  | 
                                                        
| 45 | 45 | $cache = new \Doctrine\Common\Cache\ApcuCache();  | 
                                                        
| 46 | 46 | break;  | 
                                                        
@@ -49,12 +49,12 @@ discard block  | 
                                                    ||
| 49 | 49 | break;  | 
                                                        
| 50 | 50 | case 'sqlite3':  | 
                                                        
| 51 | 51 | $db = new \SQLite3($this->config['sqlite3_db']);  | 
                                                        
| 52 | - $cache = new \Doctrine\Common\Cache\SQLite3Cache($db, $this->config['sqlite3_table']);  | 
                                                        |
| 52 | + $cache = new \Doctrine\Common\Cache\SQLite3Cache($db, $this->config['sqlite3_table']);  | 
                                                        |
| 53 | 53 | break;  | 
                                                        
| 54 | - default:  | 
                                                        |
| 54 | + default:  | 
                                                        |
| 55 | 55 |                            throw new CacheException('Invalid cache system'); | 
                                                        
| 56 | - break;  | 
                                                        |
| 57 | - }  | 
                                                        |
| 58 | - return $cache;  | 
                                                        |
| 59 | - }  | 
                                                        |
| 56 | + break;  | 
                                                        |
| 57 | + }  | 
                                                        |
| 58 | + return $cache;  | 
                                                        |
| 59 | + }  | 
                                                        |
| 60 | 60 | }  | 
                                                        
@@ -101,12 +101,12 @@ discard block  | 
                                                    ||
| 101 | 101 | $this->curlInfo = $curlInfo;  | 
                                                        
| 102 | 102 | }  | 
                                                        
| 103 | 103 | |
| 104 | - public function isError ()  | 
                                                        |
| 104 | + public function isError()  | 
                                                        |
| 105 | 105 |        { | 
                                                        
| 106 | 106 | return isset($this->getResponseObject()->errors) && $this->getResponseObject()->errors;  | 
                                                        
| 107 | 107 | }  | 
                                                        
| 108 | 108 | |
| 109 | - public function getDescription ()  | 
                                                        |
| 109 | + public function getDescription()  | 
                                                        |
| 110 | 110 |        { | 
                                                        
| 111 | 111 | return $this->getResponseObject()->description;  | 
                                                        
| 112 | 112 | }  | 
                                                        
@@ -126,7 +126,7 @@ discard block  | 
                                                    ||
| 126 | 126 | return json_decode($this->body);  | 
                                                        
| 127 | 127 | }  | 
                                                        
| 128 | 128 | |
| 129 | - public function getResponseArray ()  | 
                                                        |
| 129 | + public function getResponseArray()  | 
                                                        |
| 130 | 130 |        { | 
                                                        
| 131 | 131 | return json_decode($this->body, true);  | 
                                                        
| 132 | 132 | }  | 
                                                        
@@ -25,161 +25,161 @@  | 
                                                    ||
| 25 | 25 | |
| 26 | 26 |  class Result { | 
                                                        
| 27 | 27 | |
| 28 | - protected $error;  | 
                                                        |
| 29 | - protected $message;  | 
                                                        |
| 30 | - protected $headers;  | 
                                                        |
| 31 | - protected $curlInfo;  | 
                                                        |
| 32 | - protected $body;  | 
                                                        |
| 33 | - protected $reasonPhrases = array(  | 
                                                        |
| 34 | - // INFORMATIONAL CODES  | 
                                                        |
| 35 | - 100 => 'Continue',  | 
                                                        |
| 36 | - 101 => 'Switching Protocols',  | 
                                                        |
| 37 | - 102 => 'Processing',  | 
                                                        |
| 38 | - // SUCCESS CODES  | 
                                                        |
| 39 | - 200 => 'OK',  | 
                                                        |
| 40 | - 201 => 'Created',  | 
                                                        |
| 41 | - 202 => 'Accepted',  | 
                                                        |
| 42 | - 203 => 'Non-Authoritative Information',  | 
                                                        |
| 43 | - 204 => 'No Content',  | 
                                                        |
| 44 | - 205 => 'Reset Content',  | 
                                                        |
| 45 | - 206 => 'Partial Content',  | 
                                                        |
| 46 | - 207 => 'Multi-status',  | 
                                                        |
| 47 | - 208 => 'Already Reported',  | 
                                                        |
| 48 | - // REDIRECTION CODES  | 
                                                        |
| 49 | - 300 => 'Multiple Choices',  | 
                                                        |
| 50 | - 301 => 'Moved Permanently',  | 
                                                        |
| 51 | - 302 => 'Found',  | 
                                                        |
| 52 | - 303 => 'See Other',  | 
                                                        |
| 53 | - 304 => 'Not Modified',  | 
                                                        |
| 54 | - 305 => 'Use Proxy',  | 
                                                        |
| 55 | - 306 => 'Switch Proxy', // Deprecated  | 
                                                        |
| 56 | - 307 => 'Temporary Redirect',  | 
                                                        |
| 57 | - // CLIENT ERROR  | 
                                                        |
| 58 | - 400 => 'Bad Request',  | 
                                                        |
| 59 | - 401 => 'Unauthorized',  | 
                                                        |
| 60 | - 402 => 'Payment Required',  | 
                                                        |
| 61 | - 403 => 'Forbidden',  | 
                                                        |
| 62 | - 404 => 'Not Found',  | 
                                                        |
| 63 | - 405 => 'Method Not Allowed',  | 
                                                        |
| 64 | - 406 => 'Not Acceptable',  | 
                                                        |
| 65 | - 407 => 'Proxy Authentication Required',  | 
                                                        |
| 66 | - 408 => 'Request Time-out',  | 
                                                        |
| 67 | - 409 => 'Conflict',  | 
                                                        |
| 68 | - 410 => 'Gone',  | 
                                                        |
| 69 | - 411 => 'Length Required',  | 
                                                        |
| 70 | - 412 => 'Precondition Failed',  | 
                                                        |
| 71 | - 413 => 'Request Entity Too Large',  | 
                                                        |
| 72 | - 414 => 'Request-URI Too Large',  | 
                                                        |
| 73 | - 415 => 'Unsupported Media Type',  | 
                                                        |
| 74 | - 416 => 'Requested range not satisfiable',  | 
                                                        |
| 75 | - 417 => 'Expectation Failed',  | 
                                                        |
| 76 | - 418 => 'I\'m a teapot',  | 
                                                        |
| 77 | - 422 => 'Unprocessable Entity',  | 
                                                        |
| 78 | - 423 => 'Locked',  | 
                                                        |
| 79 | - 424 => 'Failed Dependency',  | 
                                                        |
| 80 | - 425 => 'Unordered Collection',  | 
                                                        |
| 81 | - 426 => 'Upgrade Required',  | 
                                                        |
| 82 | - 428 => 'Precondition Required',  | 
                                                        |
| 83 | - 429 => 'Too Many Requests',  | 
                                                        |
| 84 | - 431 => 'Request Header Fields Too Large',  | 
                                                        |
| 85 | - // SERVER ERROR  | 
                                                        |
| 86 | - 500 => 'Internal Server Error',  | 
                                                        |
| 87 | - 501 => 'Not Implemented',  | 
                                                        |
| 88 | - 502 => 'Bad Gateway',  | 
                                                        |
| 89 | - 503 => 'Service Unavailable',  | 
                                                        |
| 90 | - 504 => 'Gateway Time-out',  | 
                                                        |
| 91 | - 505 => 'HTTP Version not supported',  | 
                                                        |
| 92 | - 506 => 'Variant Also Negotiates',  | 
                                                        |
| 93 | - 507 => 'Insufficient Storage',  | 
                                                        |
| 94 | - 508 => 'Loop Detected',  | 
                                                        |
| 95 | - 511 => 'Network Authentication Required'  | 
                                                        |
| 96 | - );  | 
                                                        |
| 97 | -  | 
                                                        |
| 98 | - public function __construct($body, $headers, $curlInfo)  | 
                                                        |
| 99 | -      { | 
                                                        |
| 100 | - $this->body = $body;  | 
                                                        |
| 101 | - $this->headers = $headers;  | 
                                                        |
| 102 | - $this->curlInfo = $curlInfo;  | 
                                                        |
| 103 | - }  | 
                                                        |
| 104 | -  | 
                                                        |
| 105 | - public function isError ()  | 
                                                        |
| 106 | -      { | 
                                                        |
| 107 | - return isset($this->getResponseObject()->errors) && $this->getResponseObject()->errors;  | 
                                                        |
| 108 | - }  | 
                                                        |
| 28 | + protected $error;  | 
                                                        |
| 29 | + protected $message;  | 
                                                        |
| 30 | + protected $headers;  | 
                                                        |
| 31 | + protected $curlInfo;  | 
                                                        |
| 32 | + protected $body;  | 
                                                        |
| 33 | + protected $reasonPhrases = array(  | 
                                                        |
| 34 | + // INFORMATIONAL CODES  | 
                                                        |
| 35 | + 100 => 'Continue',  | 
                                                        |
| 36 | + 101 => 'Switching Protocols',  | 
                                                        |
| 37 | + 102 => 'Processing',  | 
                                                        |
| 38 | + // SUCCESS CODES  | 
                                                        |
| 39 | + 200 => 'OK',  | 
                                                        |
| 40 | + 201 => 'Created',  | 
                                                        |
| 41 | + 202 => 'Accepted',  | 
                                                        |
| 42 | + 203 => 'Non-Authoritative Information',  | 
                                                        |
| 43 | + 204 => 'No Content',  | 
                                                        |
| 44 | + 205 => 'Reset Content',  | 
                                                        |
| 45 | + 206 => 'Partial Content',  | 
                                                        |
| 46 | + 207 => 'Multi-status',  | 
                                                        |
| 47 | + 208 => 'Already Reported',  | 
                                                        |
| 48 | + // REDIRECTION CODES  | 
                                                        |
| 49 | + 300 => 'Multiple Choices',  | 
                                                        |
| 50 | + 301 => 'Moved Permanently',  | 
                                                        |
| 51 | + 302 => 'Found',  | 
                                                        |
| 52 | + 303 => 'See Other',  | 
                                                        |
| 53 | + 304 => 'Not Modified',  | 
                                                        |
| 54 | + 305 => 'Use Proxy',  | 
                                                        |
| 55 | + 306 => 'Switch Proxy', // Deprecated  | 
                                                        |
| 56 | + 307 => 'Temporary Redirect',  | 
                                                        |
| 57 | + // CLIENT ERROR  | 
                                                        |
| 58 | + 400 => 'Bad Request',  | 
                                                        |
| 59 | + 401 => 'Unauthorized',  | 
                                                        |
| 60 | + 402 => 'Payment Required',  | 
                                                        |
| 61 | + 403 => 'Forbidden',  | 
                                                        |
| 62 | + 404 => 'Not Found',  | 
                                                        |
| 63 | + 405 => 'Method Not Allowed',  | 
                                                        |
| 64 | + 406 => 'Not Acceptable',  | 
                                                        |
| 65 | + 407 => 'Proxy Authentication Required',  | 
                                                        |
| 66 | + 408 => 'Request Time-out',  | 
                                                        |
| 67 | + 409 => 'Conflict',  | 
                                                        |
| 68 | + 410 => 'Gone',  | 
                                                        |
| 69 | + 411 => 'Length Required',  | 
                                                        |
| 70 | + 412 => 'Precondition Failed',  | 
                                                        |
| 71 | + 413 => 'Request Entity Too Large',  | 
                                                        |
| 72 | + 414 => 'Request-URI Too Large',  | 
                                                        |
| 73 | + 415 => 'Unsupported Media Type',  | 
                                                        |
| 74 | + 416 => 'Requested range not satisfiable',  | 
                                                        |
| 75 | + 417 => 'Expectation Failed',  | 
                                                        |
| 76 | + 418 => 'I\'m a teapot',  | 
                                                        |
| 77 | + 422 => 'Unprocessable Entity',  | 
                                                        |
| 78 | + 423 => 'Locked',  | 
                                                        |
| 79 | + 424 => 'Failed Dependency',  | 
                                                        |
| 80 | + 425 => 'Unordered Collection',  | 
                                                        |
| 81 | + 426 => 'Upgrade Required',  | 
                                                        |
| 82 | + 428 => 'Precondition Required',  | 
                                                        |
| 83 | + 429 => 'Too Many Requests',  | 
                                                        |
| 84 | + 431 => 'Request Header Fields Too Large',  | 
                                                        |
| 85 | + // SERVER ERROR  | 
                                                        |
| 86 | + 500 => 'Internal Server Error',  | 
                                                        |
| 87 | + 501 => 'Not Implemented',  | 
                                                        |
| 88 | + 502 => 'Bad Gateway',  | 
                                                        |
| 89 | + 503 => 'Service Unavailable',  | 
                                                        |
| 90 | + 504 => 'Gateway Time-out',  | 
                                                        |
| 91 | + 505 => 'HTTP Version not supported',  | 
                                                        |
| 92 | + 506 => 'Variant Also Negotiates',  | 
                                                        |
| 93 | + 507 => 'Insufficient Storage',  | 
                                                        |
| 94 | + 508 => 'Loop Detected',  | 
                                                        |
| 95 | + 511 => 'Network Authentication Required'  | 
                                                        |
| 96 | + );  | 
                                                        |
| 97 | +  | 
                                                        |
| 98 | + public function __construct($body, $headers, $curlInfo)  | 
                                                        |
| 99 | +       { | 
                                                        |
| 100 | + $this->body = $body;  | 
                                                        |
| 101 | + $this->headers = $headers;  | 
                                                        |
| 102 | + $this->curlInfo = $curlInfo;  | 
                                                        |
| 103 | + }  | 
                                                        |
| 104 | +  | 
                                                        |
| 105 | + public function isError ()  | 
                                                        |
| 106 | +       { | 
                                                        |
| 107 | + return isset($this->getResponseObject()->errors) && $this->getResponseObject()->errors;  | 
                                                        |
| 108 | + }  | 
                                                        |
| 109 | 109 | |
| 110 | - public function getDescription ()  | 
                                                        |
| 111 | -      { | 
                                                        |
| 112 | - return $this->getResponseObject()->description;  | 
                                                        |
| 113 | - }  | 
                                                        |
| 114 | -  | 
                                                        |
| 115 | - public function getHeaders()  | 
                                                        |
| 116 | -      { | 
                                                        |
| 117 | - return $this->headers;  | 
                                                        |
| 118 | - }  | 
                                                        |
| 119 | -  | 
                                                        |
| 120 | - public function getResponse()  | 
                                                        |
| 121 | -      { | 
                                                        |
| 122 | - return $this->body;  | 
                                                        |
| 123 | - }  | 
                                                        |
| 124 | -  | 
                                                        |
| 125 | - public function getResponseObject()  | 
                                                        |
| 126 | -      { | 
                                                        |
| 127 | - return json_decode($this->body);  | 
                                                        |
| 128 | - }  | 
                                                        |
| 129 | -  | 
                                                        |
| 130 | - public function getResponseArray ()  | 
                                                        |
| 131 | -      { | 
                                                        |
| 132 | - return json_decode($this->body, true);  | 
                                                        |
| 133 | - }  | 
                                                        |
| 134 | -  | 
                                                        |
| 135 | - public function getResponseCode()  | 
                                                        |
| 136 | -      { | 
                                                        |
| 137 | - return $this->curlInfo['http_code'];  | 
                                                        |
| 138 | - }  | 
                                                        |
| 139 | -  | 
                                                        |
| 140 | - public function getReasonPhrase()  | 
                                                        |
| 141 | -      { | 
                                                        |
| 142 | - return $this->reasonPhrases[$this->curlInfo['http_code']];  | 
                                                        |
| 143 | - }  | 
                                                        |
| 144 | -  | 
                                                        |
| 145 | - public function getContentType()  | 
                                                        |
| 146 | -      { | 
                                                        |
| 147 | - return $this->curlInfo['content_type'];  | 
                                                        |
| 148 | - }  | 
                                                        |
| 149 | -  | 
                                                        |
| 150 | - public function isOk()  | 
                                                        |
| 151 | -      { | 
                                                        |
| 152 | - return ($this->curlInfo['http_code'] === 200);  | 
                                                        |
| 153 | - }  | 
                                                        |
| 154 | -  | 
                                                        |
| 155 | - public function isSuccess()  | 
                                                        |
| 156 | -      { | 
                                                        |
| 157 | - return (200 <= $this->curlInfo['http_code'] && 300 > $this->curlInfo['http_code']);  | 
                                                        |
| 158 | - }  | 
                                                        |
| 159 | -  | 
                                                        |
| 160 | - public function isNotFound()  | 
                                                        |
| 161 | -      { | 
                                                        |
| 162 | - return ($this->curlInfo['http_code'] === 404);  | 
                                                        |
| 163 | - }  | 
                                                        |
| 164 | -  | 
                                                        |
| 165 | - public function isInformational()  | 
                                                        |
| 166 | -      { | 
                                                        |
| 167 | - return ($this->curlInfo['http_code'] >= 100 && $this->curlInfo['http_code'] < 200);  | 
                                                        |
| 168 | - }  | 
                                                        |
| 169 | -  | 
                                                        |
| 170 | - public function isRedirect()  | 
                                                        |
| 171 | -      { | 
                                                        |
| 172 | - return (300 <= $this->curlInfo['http_code'] && 400 > $this->curlInfo['http_code']);  | 
                                                        |
| 173 | - }  | 
                                                        |
| 174 | -  | 
                                                        |
| 175 | - public function isClientError()  | 
                                                        |
| 176 | -      { | 
                                                        |
| 177 | - return ($this->curlInfo['http_code'] < 500 && $this->curlInfo['http_code'] >= 400);  | 
                                                        |
| 178 | - }  | 
                                                        |
| 179 | -  | 
                                                        |
| 180 | - public function isServerError()  | 
                                                        |
| 181 | -      { | 
                                                        |
| 182 | - return (500 <= $this->curlInfo['http_code'] && 600 > $this->curlInfo['http_code']);  | 
                                                        |
| 183 | - }  | 
                                                        |
| 110 | + public function getDescription ()  | 
                                                        |
| 111 | +       { | 
                                                        |
| 112 | + return $this->getResponseObject()->description;  | 
                                                        |
| 113 | + }  | 
                                                        |
| 114 | +  | 
                                                        |
| 115 | + public function getHeaders()  | 
                                                        |
| 116 | +       { | 
                                                        |
| 117 | + return $this->headers;  | 
                                                        |
| 118 | + }  | 
                                                        |
| 119 | +  | 
                                                        |
| 120 | + public function getResponse()  | 
                                                        |
| 121 | +       { | 
                                                        |
| 122 | + return $this->body;  | 
                                                        |
| 123 | + }  | 
                                                        |
| 124 | +  | 
                                                        |
| 125 | + public function getResponseObject()  | 
                                                        |
| 126 | +       { | 
                                                        |
| 127 | + return json_decode($this->body);  | 
                                                        |
| 128 | + }  | 
                                                        |
| 129 | +  | 
                                                        |
| 130 | + public function getResponseArray ()  | 
                                                        |
| 131 | +       { | 
                                                        |
| 132 | + return json_decode($this->body, true);  | 
                                                        |
| 133 | + }  | 
                                                        |
| 134 | +  | 
                                                        |
| 135 | + public function getResponseCode()  | 
                                                        |
| 136 | +       { | 
                                                        |
| 137 | + return $this->curlInfo['http_code'];  | 
                                                        |
| 138 | + }  | 
                                                        |
| 139 | +  | 
                                                        |
| 140 | + public function getReasonPhrase()  | 
                                                        |
| 141 | +       { | 
                                                        |
| 142 | + return $this->reasonPhrases[$this->curlInfo['http_code']];  | 
                                                        |
| 143 | + }  | 
                                                        |
| 144 | +  | 
                                                        |
| 145 | + public function getContentType()  | 
                                                        |
| 146 | +       { | 
                                                        |
| 147 | + return $this->curlInfo['content_type'];  | 
                                                        |
| 148 | + }  | 
                                                        |
| 149 | +  | 
                                                        |
| 150 | + public function isOk()  | 
                                                        |
| 151 | +       { | 
                                                        |
| 152 | + return ($this->curlInfo['http_code'] === 200);  | 
                                                        |
| 153 | + }  | 
                                                        |
| 154 | +  | 
                                                        |
| 155 | + public function isSuccess()  | 
                                                        |
| 156 | +       { | 
                                                        |
| 157 | + return (200 <= $this->curlInfo['http_code'] && 300 > $this->curlInfo['http_code']);  | 
                                                        |
| 158 | + }  | 
                                                        |
| 159 | +  | 
                                                        |
| 160 | + public function isNotFound()  | 
                                                        |
| 161 | +       { | 
                                                        |
| 162 | + return ($this->curlInfo['http_code'] === 404);  | 
                                                        |
| 163 | + }  | 
                                                        |
| 164 | +  | 
                                                        |
| 165 | + public function isInformational()  | 
                                                        |
| 166 | +       { | 
                                                        |
| 167 | + return ($this->curlInfo['http_code'] >= 100 && $this->curlInfo['http_code'] < 200);  | 
                                                        |
| 168 | + }  | 
                                                        |
| 169 | +  | 
                                                        |
| 170 | + public function isRedirect()  | 
                                                        |
| 171 | +       { | 
                                                        |
| 172 | + return (300 <= $this->curlInfo['http_code'] && 400 > $this->curlInfo['http_code']);  | 
                                                        |
| 173 | + }  | 
                                                        |
| 174 | +  | 
                                                        |
| 175 | + public function isClientError()  | 
                                                        |
| 176 | +       { | 
                                                        |
| 177 | + return ($this->curlInfo['http_code'] < 500 && $this->curlInfo['http_code'] >= 400);  | 
                                                        |
| 178 | + }  | 
                                                        |
| 179 | +  | 
                                                        |
| 180 | + public function isServerError()  | 
                                                        |
| 181 | +       { | 
                                                        |
| 182 | + return (500 <= $this->curlInfo['http_code'] && 600 > $this->curlInfo['http_code']);  | 
                                                        |
| 183 | + }  | 
                                                        |
| 184 | 184 | |
| 185 | 185 | }  | 
                                                        
@@ -43,7 +43,7 @@ discard block  | 
                                                    ||
| 43 | 43 |             {  | 
                                                        
| 44 | 44 |                    if (!function_exists('curl_init'))  | 
                                                        
| 45 | 45 |                    {  | 
                                                        
| 46 | -                      throw new CurlException ("cURL is not available. This API wrapper cannot be used.");  | 
                                                        |
| 46 | +                      throw new CurlException("cURL is not available. This API wrapper cannot be used.");  | 
                                                        |
| 47 | 47 | }  | 
                                                        
| 48 | 48 | |
| 49 | 49 | if (isset($api_key))  | 
                                                        
@@ -130,7 +130,7 @@ discard block  | 
                                                    ||
| 130 | 130 | case 'GET':  | 
                                                        
| 131 | 131 | curl_setopt($ch, CURLOPT_HTTPGET, true);  | 
                                                        
| 132 | 132 |                                       if (!empty($params)) { | 
                                                        
| 133 | - $url .= '?' . http_build_query($params);  | 
                                                        |
| 133 | + $url .= '?'.http_build_query($params);  | 
                                                        |
| 134 | 134 | curl_setopt($ch, CURLOPT_URL, $url);  | 
                                                        
| 135 | 135 | }  | 
                                                        
| 136 | 136 | break;  | 
                                                        
@@ -165,7 +165,7 @@ discard block  | 
                                                    ||
| 165 | 165 | $headers = array();  | 
                                                        
| 166 | 166 | $key = '';  | 
                                                        
| 167 | 167 | |
| 168 | -                       foreach(explode("\n", $raw_headers) as $i => $h) { | 
                                                        |
| 168 | +                       foreach (explode("\n", $raw_headers) as $i => $h) { | 
                                                        |
| 169 | 169 |                                 $h = explode(':', $h, 2); | 
                                                        
| 170 | 170 | |
| 171 | 171 |                                 if (isset($h[1])) { | 
                                                        
@@ -243,17 +243,17 @@ discard block  | 
                                                    ||
| 243 | 243 | return $this->curlInfo;  | 
                                                        
| 244 | 244 | }  | 
                                                        
| 245 | 245 | |
| 246 | - public function isCurlError ()  | 
                                                        |
| 246 | + public function isCurlError()  | 
                                                        |
| 247 | 247 |             { | 
                                                        
| 248 | 248 | return (bool) $this->curlErrno;  | 
                                                        
| 249 | 249 | }  | 
                                                        
| 250 | 250 | |
| 251 | - public function getCurlErrno ()  | 
                                                        |
| 251 | + public function getCurlErrno()  | 
                                                        |
| 252 | 252 |             { | 
                                                        
| 253 | 253 | return $this->curlErrno;  | 
                                                        
| 254 | 254 | }  | 
                                                        
| 255 | 255 | |
| 256 | - public function getCurlError ()  | 
                                                        |
| 256 | + public function getCurlError()  | 
                                                        |
| 257 | 257 |             { | 
                                                        
| 258 | 258 | return $this->curlError;  | 
                                                        
| 259 | 259 | }  | 
                                                        
@@ -169,21 +169,20 @@  | 
                                                    ||
| 169 | 169 |                                 $h = explode(':', $h, 2); | 
                                                        
| 170 | 170 | |
| 171 | 171 |                                 if (isset($h[1])) { | 
                                                        
| 172 | - if (!isset($headers[$h[0]]))  | 
                                                        |
| 173 | - $headers[$h[0]] = trim($h[1]);  | 
                                                        |
| 174 | -                                   elseif (is_array($headers[$h[0]])) { | 
                                                        |
| 172 | +                                   if (!isset($headers[$h[0]])) { | 
                                                        |
| 173 | + $headers[$h[0]] = trim($h[1]);  | 
                                                        |
| 174 | +                                   } elseif (is_array($headers[$h[0]])) { | 
                                                        |
| 175 | 175 | $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));  | 
                                                        
| 176 | - }  | 
                                                        |
| 177 | -                                   else { | 
                                                        |
| 176 | +                                   } else { | 
                                                        |
| 178 | 177 | $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));  | 
                                                        
| 179 | 178 | }  | 
                                                        
| 180 | 179 | $key = $h[0];  | 
                                                        
| 181 | - }  | 
                                                        |
| 182 | -                               else {  | 
                                                        |
| 183 | - if (substr($h[0], 0, 1) == "\t")  | 
                                                        |
| 184 | - $headers[$key] .= "\r\n\t".trim($h[0]);  | 
                                                        |
| 185 | - elseif (!$key)  | 
                                                        |
| 186 | - $headers[0] = trim($h[0]);  | 
                                                        |
| 180 | +                               } else {  | 
                                                        |
| 181 | +                                     if (substr($h[0], 0, 1) == "\t") { | 
                                                        |
| 182 | + $headers[$key] .= "\r\n\t".trim($h[0]);  | 
                                                        |
| 183 | +                                     } elseif (!$key) { | 
                                                        |
| 184 | + $headers[0] = trim($h[0]);  | 
                                                        |
| 185 | + }  | 
                                                        |
| 187 | 186 | }  | 
                                                        
| 188 | 187 | }  | 
                                                        
| 189 | 188 | return $headers;  | 
                                                        
@@ -26,237 +26,237 @@  | 
                                                    ||
| 26 | 26 | |
| 27 | 27 |  class Api implements ApiInterface { | 
                                                        
| 28 | 28 | |
| 29 | - protected $_api_key_var = 'Authorization: Bearer ';  | 
                                                        |
| 30 | - protected $_api_key;  | 
                                                        |
| 31 | - protected $_timeout = 30;  | 
                                                        |
| 32 | - protected $_verify_ssl = true;  | 
                                                        |
| 33 | - protected $_verify_host = 2;  | 
                                                        |
| 34 | - protected $curlErrno = false;  | 
                                                        |
| 35 | - protected $curlError = false;  | 
                                                        |
| 36 | - protected $curlProxy = false;  | 
                                                        |
| 37 | - protected $response = false;  | 
                                                        |
| 38 | - protected $request = array();  | 
                                                        |
| 39 | - protected $json = true;  | 
                                                        |
| 40 | - protected $curlInfo;  | 
                                                        |
| 41 | - protected $_curl_callback;  | 
                                                        |
| 29 | + protected $_api_key_var = 'Authorization: Bearer ';  | 
                                                        |
| 30 | + protected $_api_key;  | 
                                                        |
| 31 | + protected $_timeout = 30;  | 
                                                        |
| 32 | + protected $_verify_ssl = true;  | 
                                                        |
| 33 | + protected $_verify_host = 2;  | 
                                                        |
| 34 | + protected $curlErrno = false;  | 
                                                        |
| 35 | + protected $curlError = false;  | 
                                                        |
| 36 | + protected $curlProxy = false;  | 
                                                        |
| 37 | + protected $response = false;  | 
                                                        |
| 38 | + protected $request = array();  | 
                                                        |
| 39 | + protected $json = true;  | 
                                                        |
| 40 | + protected $curlInfo;  | 
                                                        |
| 41 | + protected $_curl_callback;  | 
                                                        |
| 42 | 42 | |
| 43 | - public function __construct($api_key = "", $basic = false)  | 
                                                        |
| 44 | -           {  | 
                                                        |
| 45 | -                  if (!function_exists('curl_init'))  | 
                                                        |
| 46 | -                  {  | 
                                                        |
| 47 | -                      throw new CurlException ("cURL is not available. This API wrapper cannot be used.");  | 
                                                        |
| 48 | - }  | 
                                                        |
| 43 | + public function __construct($api_key = "", $basic = false)  | 
                                                        |
| 44 | +              {  | 
                                                        |
| 45 | +                     if (!function_exists('curl_init'))  | 
                                                        |
| 46 | +                     {  | 
                                                        |
| 47 | +                            throw new CurlException ("cURL is not available. This API wrapper cannot be used.");  | 
                                                        |
| 48 | + }  | 
                                                        |
| 49 | 49 | |
| 50 | - if (isset($api_key))  | 
                                                        |
| 51 | -                  { | 
                                                        |
| 52 | - $this->setApiKey($api_key);  | 
                                                        |
| 53 | - }  | 
                                                        |
| 50 | + if (isset($api_key))  | 
                                                        |
| 51 | +                     { | 
                                                        |
| 52 | + $this->setApiKey($api_key);  | 
                                                        |
| 53 | + }  | 
                                                        |
| 54 | 54 | |
| 55 | - if ($basic == true)  | 
                                                        |
| 56 | -                  { | 
                                                        |
| 57 | - $this->_api_key_var = 'Authorization: Basic ';  | 
                                                        |
| 58 | - $this->json = false;  | 
                                                        |
| 59 | - }  | 
                                                        |
| 60 | - }  | 
                                                        |
| 55 | + if ($basic == true)  | 
                                                        |
| 56 | +                     { | 
                                                        |
| 57 | + $this->_api_key_var = 'Authorization: Basic ';  | 
                                                        |
| 58 | + $this->json = false;  | 
                                                        |
| 59 | + }  | 
                                                        |
| 60 | + }  | 
                                                        |
| 61 | 61 | |
| 62 | - public function enableJson()  | 
                                                        |
| 63 | -           { | 
                                                        |
| 64 | - $this->_api_key_var = 'Authorization: Bearer ';  | 
                                                        |
| 65 | - $this->json = true;  | 
                                                        |
| 66 | - }  | 
                                                        |
| 62 | + public function enableJson()  | 
                                                        |
| 63 | +              { | 
                                                        |
| 64 | + $this->_api_key_var = 'Authorization: Bearer ';  | 
                                                        |
| 65 | + $this->json = true;  | 
                                                        |
| 66 | + }  | 
                                                        |
| 67 | 67 | |
| 68 | - public function setApiKey($api_key)  | 
                                                        |
| 69 | -           {  | 
                                                        |
| 70 | - $this->_api_key = $api_key;  | 
                                                        |
| 71 | - }  | 
                                                        |
| 68 | + public function setApiKey($api_key)  | 
                                                        |
| 69 | +              {  | 
                                                        |
| 70 | + $this->_api_key = $api_key;  | 
                                                        |
| 71 | + }  | 
                                                        |
| 72 | 72 | |
| 73 | - public function enableSslVerification()  | 
                                                        |
| 74 | -           {  | 
                                                        |
| 75 | - $this->_verify_ssl = true;  | 
                                                        |
| 76 | - $this->_verify_host = 2;  | 
                                                        |
| 77 | - }  | 
                                                        |
| 73 | + public function enableSslVerification()  | 
                                                        |
| 74 | +              {  | 
                                                        |
| 75 | + $this->_verify_ssl = true;  | 
                                                        |
| 76 | + $this->_verify_host = 2;  | 
                                                        |
| 77 | + }  | 
                                                        |
| 78 | 78 | |
| 79 | - public function disableSslVerification()  | 
                                                        |
| 80 | -           {  | 
                                                        |
| 81 | - $this->_verify_ssl = false;  | 
                                                        |
| 82 | - $this->_verify_host = 0;  | 
                                                        |
| 83 | - }  | 
                                                        |
| 79 | + public function disableSslVerification()  | 
                                                        |
| 80 | +              {  | 
                                                        |
| 81 | + $this->_verify_ssl = false;  | 
                                                        |
| 82 | + $this->_verify_host = 0;  | 
                                                        |
| 83 | + }  | 
                                                        |
| 84 | 84 | |
| 85 | - public function setTimeout($timeout)  | 
                                                        |
| 86 | -           {  | 
                                                        |
| 87 | - $this->_timeout = $timeout;  | 
                                                        |
| 88 | - }  | 
                                                        |
| 85 | + public function setTimeout($timeout)  | 
                                                        |
| 86 | +              {  | 
                                                        |
| 87 | + $this->_timeout = $timeout;  | 
                                                        |
| 88 | + }  | 
                                                        |
| 89 | 89 | |
| 90 | - public function setCurlProxy($proxy)  | 
                                                        |
| 91 | -           {   | 
                                                        |
| 92 | - $this->curlProxy = $proxy;  | 
                                                        |
| 93 | - }  | 
                                                        |
| 90 | + public function setCurlProxy($proxy)  | 
                                                        |
| 91 | +              {   | 
                                                        |
| 92 | + $this->curlProxy = $proxy;  | 
                                                        |
| 93 | + }  | 
                                                        |
| 94 | 94 | |
| 95 | - public function setCurlCallback($callback)  | 
                                                        |
| 96 | -           {  | 
                                                        |
| 97 | - $this->_curl_callback = $callback;  | 
                                                        |
| 98 | - }  | 
                                                        |
| 95 | + public function setCurlCallback($callback)  | 
                                                        |
| 96 | +              {  | 
                                                        |
| 97 | + $this->_curl_callback = $callback;  | 
                                                        |
| 98 | + }  | 
                                                        |
| 99 | 99 | |
| 100 | - private function _call($url, $params = null, $headers = null, $method = "GET")  | 
                                                        |
| 101 | -           { | 
                                                        |
| 102 | - $ch = curl_init();  | 
                                                        |
| 103 | - curl_setopt($ch, CURLOPT_URL, $url);  | 
                                                        |
| 104 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);  | 
                                                        |
| 105 | - curl_setopt($ch, CURLOPT_TIMEOUT, $this->_timeout);  | 
                                                        |
| 106 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  | 
                                                        |
| 107 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->_verify_ssl);  | 
                                                        |
| 108 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->_verify_host);  | 
                                                        |
| 109 | - curl_setopt($ch, CURLOPT_HEADER, true);  | 
                                                        |
| 110 | - curl_setopt($ch, CURLINFO_HEADER_OUT, true);  | 
                                                        |
| 111 | -                  if ($this->curlProxy) {   | 
                                                        |
| 112 | - curl_setopt($ch, CURLOPT_PROXY, $this->curlProxy);  | 
                                                        |
| 113 | - }  | 
                                                        |
| 114 | -                  if ($this->_curl_callback) {  | 
                                                        |
| 115 | - call_user_func($this->_curl_callback, $ch, $params, $headers, $method);  | 
                                                        |
| 116 | - }  | 
                                                        |
| 117 | -                  switch (strtoupper($method)) {  | 
                                                        |
| 118 | - case 'PUT':  | 
                                                        |
| 100 | + private function _call($url, $params = null, $headers = null, $method = "GET")  | 
                                                        |
| 101 | +              { | 
                                                        |
| 102 | + $ch = curl_init();  | 
                                                        |
| 103 | + curl_setopt($ch, CURLOPT_URL, $url);  | 
                                                        |
| 104 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);  | 
                                                        |
| 105 | + curl_setopt($ch, CURLOPT_TIMEOUT, $this->_timeout);  | 
                                                        |
| 106 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  | 
                                                        |
| 107 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->_verify_ssl);  | 
                                                        |
| 108 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->_verify_host);  | 
                                                        |
| 109 | + curl_setopt($ch, CURLOPT_HEADER, true);  | 
                                                        |
| 110 | + curl_setopt($ch, CURLINFO_HEADER_OUT, true);  | 
                                                        |
| 111 | +                     if ($this->curlProxy) {   | 
                                                        |
| 112 | + curl_setopt($ch, CURLOPT_PROXY, $this->curlProxy);  | 
                                                        |
| 113 | + }  | 
                                                        |
| 114 | +                     if ($this->_curl_callback) {  | 
                                                        |
| 115 | + call_user_func($this->_curl_callback, $ch, $params, $headers, $method);  | 
                                                        |
| 116 | + }  | 
                                                        |
| 117 | +                     switch (strtoupper($method)) {  | 
                                                        |
| 118 | + case 'PUT':  | 
                                                        |
| 119 | 119 | case 'PATCH':  | 
                                                        
| 120 | 120 | case 'DELETE':  | 
                                                        
| 121 | 121 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method));  | 
                                                        
| 122 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));  | 
                                                        |
| 123 | - break;  | 
                                                        |
| 124 | - case 'POST':  | 
                                                        |
| 122 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));  | 
                                                        |
| 123 | + break;  | 
                                                        |
| 124 | + case 'POST':  | 
                                                        |
| 125 | 125 | curl_setopt($ch, CURLOPT_POST, true);  | 
                                                        
| 126 | -                                      if ($this->json === true) { | 
                                                        |
| 126 | +                                          if ($this->json === true) { | 
                                                        |
| 127 | 127 | $params = json_encode($params);  | 
                                                        
| 128 | - }  | 
                                                        |
| 129 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $params);  | 
                                                        |
| 130 | - break;  | 
                                                        |
| 131 | - case 'GET':  | 
                                                        |
| 128 | + }  | 
                                                        |
| 129 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $params);  | 
                                                        |
| 130 | + break;  | 
                                                        |
| 131 | + case 'GET':  | 
                                                        |
| 132 | 132 | curl_setopt($ch, CURLOPT_HTTPGET, true);  | 
                                                        
| 133 | -                                     if (!empty($params)) { | 
                                                        |
| 134 | - $url .= '?' . http_build_query($params);  | 
                                                        |
| 135 | - curl_setopt($ch, CURLOPT_URL, $url);  | 
                                                        |
| 136 | - }  | 
                                                        |
| 137 | - break;  | 
                                                        |
| 138 | - }  | 
                                                        |
| 133 | +                                          if (!empty($params)) { | 
                                                        |
| 134 | + $url .= '?' . http_build_query($params);  | 
                                                        |
| 135 | + curl_setopt($ch, CURLOPT_URL, $url);  | 
                                                        |
| 136 | + }  | 
                                                        |
| 137 | + break;  | 
                                                        |
| 138 | + }  | 
                                                        |
| 139 | 139 | |
| 140 | - $headers[] = $this->_api_key_var.$this->_api_key;  | 
                                                        |
| 141 | -                  if ($this->json === true) { | 
                                                        |
| 142 | - $headers[] = 'Content-Type: application/json';  | 
                                                        |
| 143 | - }  | 
                                                        |
| 140 | + $headers[] = $this->_api_key_var.$this->_api_key;  | 
                                                        |
| 141 | +                     if ($this->json === true) { | 
                                                        |
| 142 | + $headers[] = 'Content-Type: application/json';  | 
                                                        |
| 143 | + }  | 
                                                        |
| 144 | 144 | |
| 145 | - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);  | 
                                                        |
| 145 | + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);  | 
                                                        |
| 146 | 146 | |
| 147 | - $this->request['method'] = strtoupper($method);  | 
                                                        |
| 148 | - $this->request['headers'] = $headers;  | 
                                                        |
| 149 | - $this->request['params'] = $params;  | 
                                                        |
| 147 | + $this->request['method'] = strtoupper($method);  | 
                                                        |
| 148 | + $this->request['headers'] = $headers;  | 
                                                        |
| 149 | + $this->request['params'] = $params;  | 
                                                        |
| 150 | 150 | |
| 151 | - $this->response = curl_exec($ch);  | 
                                                        |
| 152 | -                  if (curl_errno($ch)) { | 
                                                        |
| 153 | - $this->curlErrno = curl_errno($ch);  | 
                                                        |
| 154 | - $this->curlError = curl_error($ch);  | 
                                                        |
| 155 | - curl_close($ch);  | 
                                                        |
| 156 | - return;  | 
                                                        |
| 157 | - }  | 
                                                        |
| 158 | - $this->curlInfo = curl_getinfo($ch);  | 
                                                        |
| 159 | - curl_close($ch);  | 
                                                        |
| 160 | - return new Result($this->_getBody(), $this->_getHeaders(), $this->curlInfo);  | 
                                                        |
| 161 | - }  | 
                                                        |
| 151 | + $this->response = curl_exec($ch);  | 
                                                        |
| 152 | +                     if (curl_errno($ch)) { | 
                                                        |
| 153 | + $this->curlErrno = curl_errno($ch);  | 
                                                        |
| 154 | + $this->curlError = curl_error($ch);  | 
                                                        |
| 155 | + curl_close($ch);  | 
                                                        |
| 156 | + return;  | 
                                                        |
| 157 | + }  | 
                                                        |
| 158 | + $this->curlInfo = curl_getinfo($ch);  | 
                                                        |
| 159 | + curl_close($ch);  | 
                                                        |
| 160 | + return new Result($this->_getBody(), $this->_getHeaders(), $this->curlInfo);  | 
                                                        |
| 161 | + }  | 
                                                        |
| 162 | 162 | |
| 163 | - private function _parseHeaders($raw_headers)  | 
                                                        |
| 164 | -           { | 
                                                        |
| 165 | -                   if (!function_exists('http_parse_headers')) { | 
                                                        |
| 166 | - $headers = array();  | 
                                                        |
| 167 | - $key = '';  | 
                                                        |
| 163 | + private function _parseHeaders($raw_headers)  | 
                                                        |
| 164 | +              { | 
                                                        |
| 165 | +                     if (!function_exists('http_parse_headers')) { | 
                                                        |
| 166 | + $headers = array();  | 
                                                        |
| 167 | + $key = '';  | 
                                                        |
| 168 | 168 | |
| 169 | -                       foreach(explode("\n", $raw_headers) as $i => $h) { | 
                                                        |
| 170 | -                               $h = explode(':', $h, 2); | 
                                                        |
| 169 | +                            foreach(explode("\n", $raw_headers) as $i => $h) { | 
                                                        |
| 170 | +                                   $h = explode(':', $h, 2); | 
                                                        |
| 171 | 171 | |
| 172 | -                               if (isset($h[1])) { | 
                                                        |
| 172 | +                                   if (isset($h[1])) { | 
                                                        |
| 173 | 173 | if (!isset($headers[$h[0]]))  | 
                                                        
| 174 | - $headers[$h[0]] = trim($h[1]);  | 
                                                        |
| 174 | + $headers[$h[0]] = trim($h[1]);  | 
                                                        |
| 175 | 175 |                                     elseif (is_array($headers[$h[0]])) { | 
                                                        
| 176 | - $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));  | 
                                                        |
| 176 | + $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));  | 
                                                        |
| 177 | 177 | }  | 
                                                        
| 178 | 178 |                                     else { | 
                                                        
| 179 | - $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));  | 
                                                        |
| 179 | + $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));  | 
                                                        |
| 180 | 180 | }  | 
                                                        
| 181 | 181 | $key = $h[0];  | 
                                                        
| 182 | - }  | 
                                                        |
| 183 | -                               else {  | 
                                                        |
| 184 | - if (substr($h[0], 0, 1) == "\t")  | 
                                                        |
| 185 | - $headers[$key] .= "\r\n\t".trim($h[0]);  | 
                                                        |
| 186 | - elseif (!$key)  | 
                                                        |
| 187 | - $headers[0] = trim($h[0]);  | 
                                                        |
| 188 | - }  | 
                                                        |
| 189 | - }  | 
                                                        |
| 190 | - return $headers;  | 
                                                        |
| 182 | + }  | 
                                                        |
| 183 | +                                   else {  | 
                                                        |
| 184 | + if (substr($h[0], 0, 1) == "\t")  | 
                                                        |
| 185 | + $headers[$key] .= "\r\n\t".trim($h[0]);  | 
                                                        |
| 186 | + elseif (!$key)  | 
                                                        |
| 187 | + $headers[0] = trim($h[0]);  | 
                                                        |
| 188 | + }  | 
                                                        |
| 189 | + }  | 
                                                        |
| 190 | + return $headers;  | 
                                                        |
| 191 | 191 | |
| 192 | -                   } else { | 
                                                        |
| 193 | - return http_parse_headers($raw_headers);  | 
                                                        |
| 194 | - }  | 
                                                        |
| 195 | - }  | 
                                                        |
| 192 | +                     } else { | 
                                                        |
| 193 | + return http_parse_headers($raw_headers);  | 
                                                        |
| 194 | + }  | 
                                                        |
| 195 | + }  | 
                                                        |
| 196 | 196 | |
| 197 | - private function _getHeaders()  | 
                                                        |
| 198 | -           { | 
                                                        |
| 199 | - return $this->_parseHeaders(substr($this->response, 0, $this->curlInfo['header_size']));  | 
                                                        |
| 200 | - }  | 
                                                        |
| 197 | + private function _getHeaders()  | 
                                                        |
| 198 | +              { | 
                                                        |
| 199 | + return $this->_parseHeaders(substr($this->response, 0, $this->curlInfo['header_size']));  | 
                                                        |
| 200 | + }  | 
                                                        |
| 201 | 201 | |
| 202 | - private function _getBody()  | 
                                                        |
| 203 | -           { | 
                                                        |
| 204 | - return substr($this->response, $this->curlInfo['header_size']);  | 
                                                        |
| 205 | - }  | 
                                                        |
| 202 | + private function _getBody()  | 
                                                        |
| 203 | +              { | 
                                                        |
| 204 | + return substr($this->response, $this->curlInfo['header_size']);  | 
                                                        |
| 205 | + }  | 
                                                        |
| 206 | 206 | |
| 207 | - public function getResponse()  | 
                                                        |
| 208 | -           { | 
                                                        |
| 209 | - return $this->response;  | 
                                                        |
| 210 | - }  | 
                                                        |
| 207 | + public function getResponse()  | 
                                                        |
| 208 | +              { | 
                                                        |
| 209 | + return $this->response;  | 
                                                        |
| 210 | + }  | 
                                                        |
| 211 | 211 | |
| 212 | - public function getRequest()  | 
                                                        |
| 213 | -           { | 
                                                        |
| 214 | - return $this->request;  | 
                                                        |
| 215 | - }  | 
                                                        |
| 212 | + public function getRequest()  | 
                                                        |
| 213 | +              { | 
                                                        |
| 214 | + return $this->request;  | 
                                                        |
| 215 | + }  | 
                                                        |
| 216 | 216 | |
| 217 | - public function get($url, $params = null, $headers = null)  | 
                                                        |
| 218 | -           { | 
                                                        |
| 219 | - return $this->_call($url, $params, $headers, $method = "GET");  | 
                                                        |
| 220 | - }  | 
                                                        |
| 217 | + public function get($url, $params = null, $headers = null)  | 
                                                        |
| 218 | +              { | 
                                                        |
| 219 | + return $this->_call($url, $params, $headers, $method = "GET");  | 
                                                        |
| 220 | + }  | 
                                                        |
| 221 | 221 | |
| 222 | - public function post($url, $params = null, $headers = null)  | 
                                                        |
| 223 | -           { | 
                                                        |
| 224 | - return $this->_call($url, $params, $headers, $method = "POST");  | 
                                                        |
| 225 | - }  | 
                                                        |
| 222 | + public function post($url, $params = null, $headers = null)  | 
                                                        |
| 223 | +              { | 
                                                        |
| 224 | + return $this->_call($url, $params, $headers, $method = "POST");  | 
                                                        |
| 225 | + }  | 
                                                        |
| 226 | 226 | |
| 227 | - public function delete($url, $params = null, $headers = null)  | 
                                                        |
| 228 | -           { | 
                                                        |
| 229 | - return $this->_call($url, $params, $headers, $method = "DELETE");  | 
                                                        |
| 230 | - }  | 
                                                        |
| 227 | + public function delete($url, $params = null, $headers = null)  | 
                                                        |
| 228 | +              { | 
                                                        |
| 229 | + return $this->_call($url, $params, $headers, $method = "DELETE");  | 
                                                        |
| 230 | + }  | 
                                                        |
| 231 | 231 | |
| 232 | - public function put($url, $params = null, $headers = null)  | 
                                                        |
| 233 | -           { | 
                                                        |
| 234 | - return $this->_call($url, $params, $headers, $method = "PUT");  | 
                                                        |
| 235 | - }  | 
                                                        |
| 232 | + public function put($url, $params = null, $headers = null)  | 
                                                        |
| 233 | +              { | 
                                                        |
| 234 | + return $this->_call($url, $params, $headers, $method = "PUT");  | 
                                                        |
| 235 | + }  | 
                                                        |
| 236 | 236 | |
| 237 | - public function patch($url, $params = null, $headers = null)  | 
                                                        |
| 238 | -           { | 
                                                        |
| 239 | - return $this->_call($url, $params, $headers, $method = "PATCH");  | 
                                                        |
| 240 | - }  | 
                                                        |
| 237 | + public function patch($url, $params = null, $headers = null)  | 
                                                        |
| 238 | +              { | 
                                                        |
| 239 | + return $this->_call($url, $params, $headers, $method = "PATCH");  | 
                                                        |
| 240 | + }  | 
                                                        |
| 241 | 241 | |
| 242 | - public function getCurlInfo()  | 
                                                        |
| 243 | -           { | 
                                                        |
| 244 | - return $this->curlInfo;  | 
                                                        |
| 245 | - }  | 
                                                        |
| 242 | + public function getCurlInfo()  | 
                                                        |
| 243 | +              { | 
                                                        |
| 244 | + return $this->curlInfo;  | 
                                                        |
| 245 | + }  | 
                                                        |
| 246 | 246 | |
| 247 | - public function isCurlError ()  | 
                                                        |
| 248 | -           { | 
                                                        |
| 249 | - return (bool) $this->curlErrno;  | 
                                                        |
| 250 | - }  | 
                                                        |
| 247 | + public function isCurlError ()  | 
                                                        |
| 248 | +              { | 
                                                        |
| 249 | + return (bool) $this->curlErrno;  | 
                                                        |
| 250 | + }  | 
                                                        |
| 251 | 251 | |
| 252 | - public function getCurlErrno ()  | 
                                                        |
| 253 | -           { | 
                                                        |
| 254 | - return $this->curlErrno;  | 
                                                        |
| 255 | - }  | 
                                                        |
| 252 | + public function getCurlErrno ()  | 
                                                        |
| 253 | +              { | 
                                                        |
| 254 | + return $this->curlErrno;  | 
                                                        |
| 255 | + }  | 
                                                        |
| 256 | 256 | |
| 257 | - public function getCurlError ()  | 
                                                        |
| 258 | -           { | 
                                                        |
| 259 | - return $this->curlError;  | 
                                                        |
| 260 | - }  | 
                                                        |
| 257 | + public function getCurlError ()  | 
                                                        |
| 258 | +              { | 
                                                        |
| 259 | + return $this->curlError;  | 
                                                        |
| 260 | + }  | 
                                                        |
| 261 | 261 | |
| 262 | 262 | }  | 
                                                        
@@ -28,112 +28,112 @@  | 
                                                    ||
| 28 | 28 | |
| 29 | 29 |  class Bitlink { | 
                                                        
| 30 | 30 | |
| 31 | - private $url;  | 
                                                        |
| 32 | - private $api;  | 
                                                        |
| 31 | + private $url;  | 
                                                        |
| 32 | + private $api;  | 
                                                        |
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api)  | 
                                                        |
| 35 | -      { | 
                                                        |
| 36 | - $this->api = $api;  | 
                                                        |
| 37 | - $this->url = 'https://api-ssl.bitly.com/v4';  | 
                                                        |
| 38 | - }  | 
                                                        |
| 34 | + public function __construct (ApiInterface $api)  | 
                                                        |
| 35 | +       { | 
                                                        |
| 36 | + $this->api = $api;  | 
                                                        |
| 37 | + $this->url = 'https://api-ssl.bitly.com/v4';  | 
                                                        |
| 38 | + }  | 
                                                        |
| 39 | 39 | |
| 40 | - /*  | 
                                                        |
| 40 | + /*  | 
                                                        |
| 41 | 41 | Get Metrics for a Bitlink by referrers by domain  | 
                                                        
| 42 | 42 | https://dev.bitly.com/v4/#operation/getMetricsForBitlinkByReferrersByDomains  | 
                                                        
| 43 | 43 | */  | 
                                                        
| 44 | - public function getMetricsForBitlinkByReferrersByDomains(string $bitlink, array $params = array())  | 
                                                        |
| 45 | -      { | 
                                                        |
| 46 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referrers_by_domains', $params);  | 
                                                        |
| 47 | - }  | 
                                                        |
| 44 | + public function getMetricsForBitlinkByReferrersByDomains(string $bitlink, array $params = array())  | 
                                                        |
| 45 | +       { | 
                                                        |
| 46 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referrers_by_domains', $params);  | 
                                                        |
| 47 | + }  | 
                                                        |
| 48 | 48 | |
| 49 | - /*  | 
                                                        |
| 49 | + /*  | 
                                                        |
| 50 | 50 | Get Metrics for a Bitlink by countries  | 
                                                        
| 51 | 51 | https://dev.bitly.com/v4/#operation/getMetricsForBitlinkByCountries  | 
                                                        
| 52 | 52 | */  | 
                                                        
| 53 | - public function getMetricsForBitlinkByCountries(string $bitlink, array $params = array())  | 
                                                        |
| 54 | -      { | 
                                                        |
| 55 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/countries', $params);  | 
                                                        |
| 56 | - }  | 
                                                        |
| 53 | + public function getMetricsForBitlinkByCountries(string $bitlink, array $params = array())  | 
                                                        |
| 54 | +       { | 
                                                        |
| 55 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/countries', $params);  | 
                                                        |
| 56 | + }  | 
                                                        |
| 57 | 57 | |
| 58 | - /*  | 
                                                        |
| 58 | + /*  | 
                                                        |
| 59 | 59 | Get Clicks for a Bitlink  | 
                                                        
| 60 | 60 | https://dev.bitly.com/v4/#operation/getClicksForBitlink  | 
                                                        
| 61 | 61 | */  | 
                                                        
| 62 | - public function getClicksForBitlink(string $bitlink, array $params = array())  | 
                                                        |
| 63 | -      { | 
                                                        |
| 64 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/clicks', $params);  | 
                                                        |
| 65 | - }  | 
                                                        |
| 62 | + public function getClicksForBitlink(string $bitlink, array $params = array())  | 
                                                        |
| 63 | +       { | 
                                                        |
| 64 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/clicks', $params);  | 
                                                        |
| 65 | + }  | 
                                                        |
| 66 | 66 | |
| 67 | - /*  | 
                                                        |
| 67 | + /*  | 
                                                        |
| 68 | 68 | Expand a Bitlink  | 
                                                        
| 69 | 69 | https://dev.bitly.com/v4/#operation/expandBitlink  | 
                                                        
| 70 | 70 | */  | 
                                                        
| 71 | - public function expandBitlink(array $params)  | 
                                                        |
| 72 | -      { | 
                                                        |
| 73 | - return $this->api->post($this->url . '/expand', $params);  | 
                                                        |
| 74 | - }  | 
                                                        |
| 71 | + public function expandBitlink(array $params)  | 
                                                        |
| 72 | +       { | 
                                                        |
| 73 | + return $this->api->post($this->url . '/expand', $params);  | 
                                                        |
| 74 | + }  | 
                                                        |
| 75 | 75 | |
| 76 | - /*  | 
                                                        |
| 76 | + /*  | 
                                                        |
| 77 | 77 | Get Metrics for a Bitlink by referrers  | 
                                                        
| 78 | 78 | https://dev.bitly.com/v4/#operation/getMetricsForBitlinkByReferrers  | 
                                                        
| 79 | 79 | */  | 
                                                        
| 80 | - public function getMetricsForBitlinkByReferrers(string $bitlink, array $params = array())  | 
                                                        |
| 81 | -      { | 
                                                        |
| 82 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referrers', $params);  | 
                                                        |
| 83 | - }  | 
                                                        |
| 80 | + public function getMetricsForBitlinkByReferrers(string $bitlink, array $params = array())  | 
                                                        |
| 81 | +       { | 
                                                        |
| 82 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referrers', $params);  | 
                                                        |
| 83 | + }  | 
                                                        |
| 84 | 84 | |
| 85 | - /*  | 
                                                        |
| 85 | + /*  | 
                                                        |
| 86 | 86 | Create a Bitlink  | 
                                                        
| 87 | 87 | https://dev.bitly.com/v4/#operation/createFullBitlink  | 
                                                        
| 88 | 88 | */  | 
                                                        
| 89 | - public function createFullBitlink(array $params)  | 
                                                        |
| 90 | -      { | 
                                                        |
| 91 | - return $this->api->post($this->url . '/bitlinks', $params);  | 
                                                        |
| 92 | - }  | 
                                                        |
| 89 | + public function createFullBitlink(array $params)  | 
                                                        |
| 90 | +       { | 
                                                        |
| 91 | + return $this->api->post($this->url . '/bitlinks', $params);  | 
                                                        |
| 92 | + }  | 
                                                        |
| 93 | 93 | |
| 94 | - /*  | 
                                                        |
| 94 | + /*  | 
                                                        |
| 95 | 95 | Update a Bitlink  | 
                                                        
| 96 | 96 | https://dev.bitly.com/v4/#operation/updateBitlink  | 
                                                        
| 97 | 97 | */  | 
                                                        
| 98 | - public function updateBitlink(string $bitlink, array $params)  | 
                                                        |
| 99 | -      { | 
                                                        |
| 100 | - return $this->api->patch($this->url . '/bitlinks/'.$bitlink, $params);  | 
                                                        |
| 101 | - }  | 
                                                        |
| 98 | + public function updateBitlink(string $bitlink, array $params)  | 
                                                        |
| 99 | +       { | 
                                                        |
| 100 | + return $this->api->patch($this->url . '/bitlinks/'.$bitlink, $params);  | 
                                                        |
| 101 | + }  | 
                                                        |
| 102 | 102 | |
| 103 | - /*  | 
                                                        |
| 103 | + /*  | 
                                                        |
| 104 | 104 | Retrieve a Bitlink  | 
                                                        
| 105 | 105 | https://dev.bitly.com/v4/#operation/getBitlink  | 
                                                        
| 106 | 106 | */  | 
                                                        
| 107 | - public function getBitlink(string $bitlink)  | 
                                                        |
| 108 | -      { | 
                                                        |
| 109 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink);  | 
                                                        |
| 110 | - }  | 
                                                        |
| 107 | + public function getBitlink(string $bitlink)  | 
                                                        |
| 108 | +       { | 
                                                        |
| 109 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink);  | 
                                                        |
| 110 | + }  | 
                                                        |
| 111 | 111 | |
| 112 | - /*  | 
                                                        |
| 112 | + /*  | 
                                                        |
| 113 | 113 | Get Clicks Summary for a Bitlink  | 
                                                        
| 114 | 114 | https://dev.bitly.com/v4/#operation/getClicksSummaryForBitlink  | 
                                                        
| 115 | 115 | */  | 
                                                        
| 116 | - public function getClicksSummaryForBitlink(string $bitlink, array $params = array())  | 
                                                        |
| 117 | -      { | 
                                                        |
| 118 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/clicks/summary', $params);  | 
                                                        |
| 119 | - }  | 
                                                        |
| 116 | + public function getClicksSummaryForBitlink(string $bitlink, array $params = array())  | 
                                                        |
| 117 | +       { | 
                                                        |
| 118 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/clicks/summary', $params);  | 
                                                        |
| 119 | + }  | 
                                                        |
| 120 | 120 | |
| 121 | - /*  | 
                                                        |
| 121 | + /*  | 
                                                        |
| 122 | 122 | Shorten a Link  | 
                                                        
| 123 | 123 | https://dev.bitly.com/v4/#operation/createBitlink  | 
                                                        
| 124 | 124 | */  | 
                                                        
| 125 | - public function createBitlink(array $params)  | 
                                                        |
| 126 | -      { | 
                                                        |
| 127 | - return $this->api->post($this->url . '/shorten', $params);  | 
                                                        |
| 128 | - }  | 
                                                        |
| 125 | + public function createBitlink(array $params)  | 
                                                        |
| 126 | +       { | 
                                                        |
| 127 | + return $this->api->post($this->url . '/shorten', $params);  | 
                                                        |
| 128 | + }  | 
                                                        |
| 129 | 129 | |
| 130 | - /*  | 
                                                        |
| 130 | + /*  | 
                                                        |
| 131 | 131 | Get Metrics for a Bitlink by referring domains  | 
                                                        
| 132 | 132 | https://dev.bitly.com/v4/#operation/getMetricsForBitlinkByReferringDomains  | 
                                                        
| 133 | 133 | */  | 
                                                        
| 134 | - public function getMetricsForBitlinkByReferringDomains(string $bitlink, array $params = array())  | 
                                                        |
| 135 | -      { | 
                                                        |
| 136 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referring_domains', $params);  | 
                                                        |
| 137 | - }  | 
                                                        |
| 134 | + public function getMetricsForBitlinkByReferringDomains(string $bitlink, array $params = array())  | 
                                                        |
| 135 | +       { | 
                                                        |
| 136 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referring_domains', $params);  | 
                                                        |
| 137 | + }  | 
                                                        |
| 138 | 138 | |
| 139 | 139 | }  | 
                                                        
@@ -31,7 +31,7 @@ discard block  | 
                                                    ||
| 31 | 31 | private $url;  | 
                                                        
| 32 | 32 | private $api;  | 
                                                        
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api)  | 
                                                        |
| 34 | + public function __construct(ApiInterface $api)  | 
                                                        |
| 35 | 35 |        { | 
                                                        
| 36 | 36 | $this->api = $api;  | 
                                                        
| 37 | 37 | $this->url = 'https://api-ssl.bitly.com/v4';  | 
                                                        
@@ -43,7 +43,7 @@ discard block  | 
                                                    ||
| 43 | 43 | */  | 
                                                        
| 44 | 44 | public function getMetricsForBitlinkByReferrersByDomains(string $bitlink, array $params = array())  | 
                                                        
| 45 | 45 |        { | 
                                                        
| 46 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referrers_by_domains', $params);  | 
                                                        |
| 46 | + return $this->api->get($this->url.'/bitlinks/'.$bitlink.'/referrers_by_domains', $params);  | 
                                                        |
| 47 | 47 | }  | 
                                                        
| 48 | 48 | |
| 49 | 49 | /*  | 
                                                        
@@ -52,7 +52,7 @@ discard block  | 
                                                    ||
| 52 | 52 | */  | 
                                                        
| 53 | 53 | public function getMetricsForBitlinkByCountries(string $bitlink, array $params = array())  | 
                                                        
| 54 | 54 |        { | 
                                                        
| 55 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/countries', $params);  | 
                                                        |
| 55 | + return $this->api->get($this->url.'/bitlinks/'.$bitlink.'/countries', $params);  | 
                                                        |
| 56 | 56 | }  | 
                                                        
| 57 | 57 | |
| 58 | 58 | /*  | 
                                                        
@@ -61,7 +61,7 @@ discard block  | 
                                                    ||
| 61 | 61 | */  | 
                                                        
| 62 | 62 | public function getClicksForBitlink(string $bitlink, array $params = array())  | 
                                                        
| 63 | 63 |        { | 
                                                        
| 64 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/clicks', $params);  | 
                                                        |
| 64 | + return $this->api->get($this->url.'/bitlinks/'.$bitlink.'/clicks', $params);  | 
                                                        |
| 65 | 65 | }  | 
                                                        
| 66 | 66 | |
| 67 | 67 | /*  | 
                                                        
@@ -70,7 +70,7 @@ discard block  | 
                                                    ||
| 70 | 70 | */  | 
                                                        
| 71 | 71 | public function expandBitlink(array $params)  | 
                                                        
| 72 | 72 |        { | 
                                                        
| 73 | - return $this->api->post($this->url . '/expand', $params);  | 
                                                        |
| 73 | + return $this->api->post($this->url.'/expand', $params);  | 
                                                        |
| 74 | 74 | }  | 
                                                        
| 75 | 75 | |
| 76 | 76 | /*  | 
                                                        
@@ -79,7 +79,7 @@ discard block  | 
                                                    ||
| 79 | 79 | */  | 
                                                        
| 80 | 80 | public function getMetricsForBitlinkByReferrers(string $bitlink, array $params = array())  | 
                                                        
| 81 | 81 |        { | 
                                                        
| 82 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referrers', $params);  | 
                                                        |
| 82 | + return $this->api->get($this->url.'/bitlinks/'.$bitlink.'/referrers', $params);  | 
                                                        |
| 83 | 83 | }  | 
                                                        
| 84 | 84 | |
| 85 | 85 | /*  | 
                                                        
@@ -88,7 +88,7 @@ discard block  | 
                                                    ||
| 88 | 88 | */  | 
                                                        
| 89 | 89 | public function createFullBitlink(array $params)  | 
                                                        
| 90 | 90 |        { | 
                                                        
| 91 | - return $this->api->post($this->url . '/bitlinks', $params);  | 
                                                        |
| 91 | + return $this->api->post($this->url.'/bitlinks', $params);  | 
                                                        |
| 92 | 92 | }  | 
                                                        
| 93 | 93 | |
| 94 | 94 | /*  | 
                                                        
@@ -97,7 +97,7 @@ discard block  | 
                                                    ||
| 97 | 97 | */  | 
                                                        
| 98 | 98 | public function updateBitlink(string $bitlink, array $params)  | 
                                                        
| 99 | 99 |        { | 
                                                        
| 100 | - return $this->api->patch($this->url . '/bitlinks/'.$bitlink, $params);  | 
                                                        |
| 100 | + return $this->api->patch($this->url.'/bitlinks/'.$bitlink, $params);  | 
                                                        |
| 101 | 101 | }  | 
                                                        
| 102 | 102 | |
| 103 | 103 | /*  | 
                                                        
@@ -106,7 +106,7 @@ discard block  | 
                                                    ||
| 106 | 106 | */  | 
                                                        
| 107 | 107 | public function getBitlink(string $bitlink)  | 
                                                        
| 108 | 108 |        { | 
                                                        
| 109 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink);  | 
                                                        |
| 109 | + return $this->api->get($this->url.'/bitlinks/'.$bitlink);  | 
                                                        |
| 110 | 110 | }  | 
                                                        
| 111 | 111 | |
| 112 | 112 | /*  | 
                                                        
@@ -115,7 +115,7 @@ discard block  | 
                                                    ||
| 115 | 115 | */  | 
                                                        
| 116 | 116 | public function getClicksSummaryForBitlink(string $bitlink, array $params = array())  | 
                                                        
| 117 | 117 |        { | 
                                                        
| 118 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/clicks/summary', $params);  | 
                                                        |
| 118 | + return $this->api->get($this->url.'/bitlinks/'.$bitlink.'/clicks/summary', $params);  | 
                                                        |
| 119 | 119 | }  | 
                                                        
| 120 | 120 | |
| 121 | 121 | /*  | 
                                                        
@@ -124,7 +124,7 @@ discard block  | 
                                                    ||
| 124 | 124 | */  | 
                                                        
| 125 | 125 | public function createBitlink(array $params)  | 
                                                        
| 126 | 126 |        { | 
                                                        
| 127 | - return $this->api->post($this->url . '/shorten', $params);  | 
                                                        |
| 127 | + return $this->api->post($this->url.'/shorten', $params);  | 
                                                        |
| 128 | 128 | }  | 
                                                        
| 129 | 129 | |
| 130 | 130 | /*  | 
                                                        
@@ -133,7 +133,7 @@ discard block  | 
                                                    ||
| 133 | 133 | */  | 
                                                        
| 134 | 134 | public function getMetricsForBitlinkByReferringDomains(string $bitlink, array $params = array())  | 
                                                        
| 135 | 135 |        { | 
                                                        
| 136 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referring_domains', $params);  | 
                                                        |
| 136 | + return $this->api->get($this->url.'/bitlinks/'.$bitlink.'/referring_domains', $params);  | 
                                                        |
| 137 | 137 | }  | 
                                                        
| 138 | 138 | |
| 139 | 139 | }  | 
                                                        
@@ -28,31 +28,31 @@  | 
                                                    ||
| 28 | 28 | |
| 29 | 29 |  class User { | 
                                                        
| 30 | 30 | |
| 31 | - private $url;  | 
                                                        |
| 32 | - private $api;  | 
                                                        |
| 31 | + private $url;  | 
                                                        |
| 32 | + private $api;  | 
                                                        |
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api)  | 
                                                        |
| 35 | -      { | 
                                                        |
| 36 | - $this->api = $api;  | 
                                                        |
| 37 | - $this->url = 'https://api-ssl.bitly.com/v4/user';  | 
                                                        |
| 38 | - }  | 
                                                        |
| 34 | + public function __construct (ApiInterface $api)  | 
                                                        |
| 35 | +       { | 
                                                        |
| 36 | + $this->api = $api;  | 
                                                        |
| 37 | + $this->url = 'https://api-ssl.bitly.com/v4/user';  | 
                                                        |
| 38 | + }  | 
                                                        |
| 39 | 39 | |
| 40 | - /*  | 
                                                        |
| 40 | + /*  | 
                                                        |
| 41 | 41 | Update a User  | 
                                                        
| 42 | 42 | https://dev.bitly.com/v4/#operation/updateUser  | 
                                                        
| 43 | 43 | */  | 
                                                        
| 44 | - public function updateUser(array $params)  | 
                                                        |
| 45 | -      { | 
                                                        |
| 46 | - return $this->api->patch($this->url, $params);  | 
                                                        |
| 47 | - }  | 
                                                        |
| 44 | + public function updateUser(array $params)  | 
                                                        |
| 45 | +       { | 
                                                        |
| 46 | + return $this->api->patch($this->url, $params);  | 
                                                        |
| 47 | + }  | 
                                                        |
| 48 | 48 | |
| 49 | - /*  | 
                                                        |
| 49 | + /*  | 
                                                        |
| 50 | 50 | Retrieve a User  | 
                                                        
| 51 | 51 | https://dev.bitly.com/v4/#operation/getUser  | 
                                                        
| 52 | 52 | */  | 
                                                        
| 53 | - public function getUser()  | 
                                                        |
| 54 | -      { | 
                                                        |
| 55 | - return $this->api->get($this->url);  | 
                                                        |
| 56 | - }  | 
                                                        |
| 53 | + public function getUser()  | 
                                                        |
| 54 | +       { | 
                                                        |
| 55 | + return $this->api->get($this->url);  | 
                                                        |
| 56 | + }  | 
                                                        |
| 57 | 57 | |
| 58 | 58 | }  | 
                                                        
@@ -31,7 +31,7 @@  | 
                                                    ||
| 31 | 31 | private $url;  | 
                                                        
| 32 | 32 | private $api;  | 
                                                        
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api)  | 
                                                        |
| 34 | + public function __construct(ApiInterface $api)  | 
                                                        |
| 35 | 35 |        { | 
                                                        
| 36 | 36 | $this->api = $api;  | 
                                                        
| 37 | 37 | $this->url = 'https://api-ssl.bitly.com/v4/user';  | 
                                                        
@@ -28,37 +28,37 @@  | 
                                                    ||
| 28 | 28 | |
| 29 | 29 |  class Auth { | 
                                                        
| 30 | 30 | |
| 31 | - private $url;  | 
                                                        |
| 32 | - private $api;  | 
                                                        |
| 31 | + private $url;  | 
                                                        |
| 32 | + private $api;  | 
                                                        |
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api, array $config)  | 
                                                        |
| 35 | -      { | 
                                                        |
| 36 | - $this->api = $api;  | 
                                                        |
| 37 | - $this->url = 'https://api-ssl.bitly.com/oauth/access_token';  | 
                                                        |
| 38 | - $key = base64_encode($config['clientid_username'].":".$config['clientsecret_password']);  | 
                                                        |
| 39 | - $api->setApiKey($key);  | 
                                                        |
| 40 | - }  | 
                                                        |
| 34 | + public function __construct (ApiInterface $api, array $config)  | 
                                                        |
| 35 | +       { | 
                                                        |
| 36 | + $this->api = $api;  | 
                                                        |
| 37 | + $this->url = 'https://api-ssl.bitly.com/oauth/access_token';  | 
                                                        |
| 38 | + $key = base64_encode($config['clientid_username'].":".$config['clientsecret_password']);  | 
                                                        |
| 39 | + $api->setApiKey($key);  | 
                                                        |
| 40 | + }  | 
                                                        |
| 41 | 41 | |
| 42 | 42 | |
| 43 | - /*  | 
                                                        |
| 43 | + /*  | 
                                                        |
| 44 | 44 | Exchanging a Username and Password for an Access Token  | 
                                                        
| 45 | 45 | https://dev.bitly.com/v4/#section/Exchanging-a-Username-and-Password-for-an-Access-Token  | 
                                                        
| 46 | 46 | */  | 
                                                        
| 47 | - public function exchangeToken(array $params)  | 
                                                        |
| 48 | -      { | 
                                                        |
| 49 | - $params['grant_type'] = 'password';  | 
                                                        |
| 50 | - $result = $this->api->post($this->url, $params);  | 
                                                        |
| 51 | - return json_decode($result->getResponse(), true)['access_token'];  | 
                                                        |
| 52 | - }  | 
                                                        |
| 47 | + public function exchangeToken(array $params)  | 
                                                        |
| 48 | +       { | 
                                                        |
| 49 | + $params['grant_type'] = 'password';  | 
                                                        |
| 50 | + $result = $this->api->post($this->url, $params);  | 
                                                        |
| 51 | + return json_decode($result->getResponse(), true)['access_token'];  | 
                                                        |
| 52 | + }  | 
                                                        |
| 53 | 53 | |
| 54 | - /*  | 
                                                        |
| 54 | + /*  | 
                                                        |
| 55 | 55 | HTTP Basic Authentication Flow  | 
                                                        
| 56 | 56 | https://dev.bitly.com/v4/#section/HTTP-Basic-Authentication-Flow  | 
                                                        
| 57 | 57 | */  | 
                                                        
| 58 | - public function basicAuthFlow(array $params)  | 
                                                        |
| 59 | -      { | 
                                                        |
| 60 | - $result = $this->api->post($this->url, $params);  | 
                                                        |
| 61 | - return $result->getResponse();  | 
                                                        |
| 62 | - }  | 
                                                        |
| 58 | + public function basicAuthFlow(array $params)  | 
                                                        |
| 59 | +       { | 
                                                        |
| 60 | + $result = $this->api->post($this->url, $params);  | 
                                                        |
| 61 | + return $result->getResponse();  | 
                                                        |
| 62 | + }  | 
                                                        |
| 63 | 63 | |
| 64 | 64 | }  | 
                                                        
@@ -31,7 +31,7 @@  | 
                                                    ||
| 31 | 31 | private $url;  | 
                                                        
| 32 | 32 | private $api;  | 
                                                        
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api, array $config)  | 
                                                        |
| 34 | + public function __construct(ApiInterface $api, array $config)  | 
                                                        |
| 35 | 35 |        { | 
                                                        
| 36 | 36 | $this->api = $api;  | 
                                                        
| 37 | 37 | $this->url = 'https://api-ssl.bitly.com/oauth/access_token';  | 
                                                        
@@ -28,40 +28,40 @@  | 
                                                    ||
| 28 | 28 | |
| 29 | 29 |  class Organization { | 
                                                        
| 30 | 30 | |
| 31 | - private $url;  | 
                                                        |
| 32 | - private $api;  | 
                                                        |
| 31 | + private $url;  | 
                                                        |
| 32 | + private $api;  | 
                                                        |
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api)  | 
                                                        |
| 35 | -      { | 
                                                        |
| 36 | - $this->api = $api;  | 
                                                        |
| 37 | - $this->url = 'https://api-ssl.bitly.com/v4/organizations';  | 
                                                        |
| 38 | - }  | 
                                                        |
| 34 | + public function __construct (ApiInterface $api)  | 
                                                        |
| 35 | +       { | 
                                                        |
| 36 | + $this->api = $api;  | 
                                                        |
| 37 | + $this->url = 'https://api-ssl.bitly.com/v4/organizations';  | 
                                                        |
| 38 | + }  | 
                                                        |
| 39 | 39 | |
| 40 | - /*  | 
                                                        |
| 40 | + /*  | 
                                                        |
| 41 | 41 | Retrieve Organizations  | 
                                                        
| 42 | 42 | https://dev.bitly.com/v4/#operation/getOrganizations  | 
                                                        
| 43 | 43 | */  | 
                                                        
| 44 | - public function getOrganizations()  | 
                                                        |
| 45 | -      { | 
                                                        |
| 46 | - return $this->api->get($this->url);  | 
                                                        |
| 47 | - }  | 
                                                        |
| 44 | + public function getOrganizations()  | 
                                                        |
| 45 | +       { | 
                                                        |
| 46 | + return $this->api->get($this->url);  | 
                                                        |
| 47 | + }  | 
                                                        |
| 48 | 48 | |
| 49 | - /*  | 
                                                        |
| 49 | + /*  | 
                                                        |
| 50 | 50 | Retrieve Organization Shorten Counts  | 
                                                        
| 51 | 51 | https://dev.bitly.com/v4/#operation/getOrganizationShortenCounts  | 
                                                        
| 52 | 52 | */  | 
                                                        
| 53 | - public function getOrganizationShortenCounts(string $organization_guid)  | 
                                                        |
| 54 | -      { | 
                                                        |
| 55 | - return $this->api->get($this->url . '/'.$organization_guid.'/shorten_counts');  | 
                                                        |
| 56 | - }  | 
                                                        |
| 53 | + public function getOrganizationShortenCounts(string $organization_guid)  | 
                                                        |
| 54 | +       { | 
                                                        |
| 55 | + return $this->api->get($this->url . '/'.$organization_guid.'/shorten_counts');  | 
                                                        |
| 56 | + }  | 
                                                        |
| 57 | 57 | |
| 58 | - /*  | 
                                                        |
| 58 | + /*  | 
                                                        |
| 59 | 59 | Retrieve an Organization  | 
                                                        
| 60 | 60 | https://dev.bitly.com/v4/#operation/getOrganization  | 
                                                        
| 61 | 61 | */  | 
                                                        
| 62 | - public function getOrganization(string $organization_guid)  | 
                                                        |
| 63 | -      { | 
                                                        |
| 64 | - return $this->api->get($this->url . '/'.$organization_guid);  | 
                                                        |
| 65 | - }  | 
                                                        |
| 62 | + public function getOrganization(string $organization_guid)  | 
                                                        |
| 63 | +       { | 
                                                        |
| 64 | + return $this->api->get($this->url . '/'.$organization_guid);  | 
                                                        |
| 65 | + }  | 
                                                        |
| 66 | 66 | |
| 67 | 67 | }  | 
                                                        
@@ -31,7 +31,7 @@ discard block  | 
                                                    ||
| 31 | 31 | private $url;  | 
                                                        
| 32 | 32 | private $api;  | 
                                                        
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api)  | 
                                                        |
| 34 | + public function __construct(ApiInterface $api)  | 
                                                        |
| 35 | 35 |        { | 
                                                        
| 36 | 36 | $this->api = $api;  | 
                                                        
| 37 | 37 | $this->url = 'https://api-ssl.bitly.com/v4/organizations';  | 
                                                        
@@ -52,7 +52,7 @@ discard block  | 
                                                    ||
| 52 | 52 | */  | 
                                                        
| 53 | 53 | public function getOrganizationShortenCounts(string $organization_guid)  | 
                                                        
| 54 | 54 |        { | 
                                                        
| 55 | - return $this->api->get($this->url . '/'.$organization_guid.'/shorten_counts');  | 
                                                        |
| 55 | + return $this->api->get($this->url.'/'.$organization_guid.'/shorten_counts');  | 
                                                        |
| 56 | 56 | }  | 
                                                        
| 57 | 57 | |
| 58 | 58 | /*  | 
                                                        
@@ -61,7 +61,7 @@ discard block  | 
                                                    ||
| 61 | 61 | */  | 
                                                        
| 62 | 62 | public function getOrganization(string $organization_guid)  | 
                                                        
| 63 | 63 |        { | 
                                                        
| 64 | - return $this->api->get($this->url . '/'.$organization_guid);  | 
                                                        |
| 64 | + return $this->api->get($this->url.'/'.$organization_guid);  | 
                                                        |
| 65 | 65 | }  | 
                                                        
| 66 | 66 | |
| 67 | 67 | }  | 
                                                        
@@ -28,85 +28,85 @@  | 
                                                    ||
| 28 | 28 | |
| 29 | 29 |  class Campaign { | 
                                                        
| 30 | 30 | |
| 31 | - private $url;  | 
                                                        |
| 32 | - private $api;  | 
                                                        |
| 31 | + private $url;  | 
                                                        |
| 32 | + private $api;  | 
                                                        |
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api)  | 
                                                        |
| 35 | -      { | 
                                                        |
| 36 | - $this->api = $api;  | 
                                                        |
| 37 | - $this->url = 'https://api-ssl.bitly.com/v4';  | 
                                                        |
| 38 | - }  | 
                                                        |
| 34 | + public function __construct (ApiInterface $api)  | 
                                                        |
| 35 | +       { | 
                                                        |
| 36 | + $this->api = $api;  | 
                                                        |
| 37 | + $this->url = 'https://api-ssl.bitly.com/v4';  | 
                                                        |
| 38 | + }  | 
                                                        |
| 39 | 39 | |
| 40 | - /*  | 
                                                        |
| 40 | + /*  | 
                                                        |
| 41 | 41 | Create Channel  | 
                                                        
| 42 | 42 | https://dev.bitly.com/v4/#operation/createChannel  | 
                                                        
| 43 | 43 | */  | 
                                                        
| 44 | - public function createChannel(array $params)  | 
                                                        |
| 45 | -      { | 
                                                        |
| 46 | - return $this->api->post($this->url . '/channels', $params);  | 
                                                        |
| 47 | - }  | 
                                                        |
| 44 | + public function createChannel(array $params)  | 
                                                        |
| 45 | +       { | 
                                                        |
| 46 | + return $this->api->post($this->url . '/channels', $params);  | 
                                                        |
| 47 | + }  | 
                                                        |
| 48 | 48 | |
| 49 | - /*  | 
                                                        |
| 49 | + /*  | 
                                                        |
| 50 | 50 | Retrieve Channels  | 
                                                        
| 51 | 51 | https://dev.bitly.com/v4/#operation/getChannels  | 
                                                        
| 52 | 52 | */  | 
                                                        
| 53 | - public function getChannels(array $params)  | 
                                                        |
| 54 | -      { | 
                                                        |
| 55 | - return $this->api->get($this->url . '/channels', $params);  | 
                                                        |
| 56 | - }  | 
                                                        |
| 53 | + public function getChannels(array $params)  | 
                                                        |
| 54 | +       { | 
                                                        |
| 55 | + return $this->api->get($this->url . '/channels', $params);  | 
                                                        |
| 56 | + }  | 
                                                        |
| 57 | 57 | |
| 58 | - /*  | 
                                                        |
| 58 | + /*  | 
                                                        |
| 59 | 59 | Create Campaign  | 
                                                        
| 60 | 60 | https://dev.bitly.com/v4/#operation/createCampaign  | 
                                                        
| 61 | 61 | */  | 
                                                        
| 62 | - public function createCampaign(array $params)  | 
                                                        |
| 63 | -      { | 
                                                        |
| 64 | - return $this->api->post($this->url . '/campaigns', $params);  | 
                                                        |
| 65 | - }  | 
                                                        |
| 62 | + public function createCampaign(array $params)  | 
                                                        |
| 63 | +       { | 
                                                        |
| 64 | + return $this->api->post($this->url . '/campaigns', $params);  | 
                                                        |
| 65 | + }  | 
                                                        |
| 66 | 66 | |
| 67 | - /*  | 
                                                        |
| 67 | + /*  | 
                                                        |
| 68 | 68 | Retrieve Campaigns  | 
                                                        
| 69 | 69 | https://dev.bitly.com/v4/#operation/getCampaigns  | 
                                                        
| 70 | 70 | */  | 
                                                        
| 71 | - public function getCampaigns(array $params)  | 
                                                        |
| 72 | -      { | 
                                                        |
| 73 | - return $this->api->get($this->url . '/campaigns', $params);  | 
                                                        |
| 74 | - }  | 
                                                        |
| 71 | + public function getCampaigns(array $params)  | 
                                                        |
| 72 | +       { | 
                                                        |
| 73 | + return $this->api->get($this->url . '/campaigns', $params);  | 
                                                        |
| 74 | + }  | 
                                                        |
| 75 | 75 | |
| 76 | - /*  | 
                                                        |
| 76 | + /*  | 
                                                        |
| 77 | 77 | Retrieve a Campaign  | 
                                                        
| 78 | 78 | https://dev.bitly.com/v4/#operation/getCampaign  | 
                                                        
| 79 | 79 | */  | 
                                                        
| 80 | - public function getCampaign(string $campaign_guid)  | 
                                                        |
| 81 | -      { | 
                                                        |
| 82 | - return $this->api->get($this->url . '/campaigns/'.$campaign_guid);  | 
                                                        |
| 83 | - }  | 
                                                        |
| 80 | + public function getCampaign(string $campaign_guid)  | 
                                                        |
| 81 | +       { | 
                                                        |
| 82 | + return $this->api->get($this->url . '/campaigns/'.$campaign_guid);  | 
                                                        |
| 83 | + }  | 
                                                        |
| 84 | 84 | |
| 85 | - /*  | 
                                                        |
| 85 | + /*  | 
                                                        |
| 86 | 86 | Update Campaign  | 
                                                        
| 87 | 87 | https://dev.bitly.com/v4/#operation/updateCampaign  | 
                                                        
| 88 | 88 | */  | 
                                                        
| 89 | - public function updateCampaign(string $campaign_guid, array $params)  | 
                                                        |
| 90 | -      { | 
                                                        |
| 91 | - return $this->api->patch($this->url . '/campaigns/'.$campaign_guid, $params);  | 
                                                        |
| 92 | - }  | 
                                                        |
| 89 | + public function updateCampaign(string $campaign_guid, array $params)  | 
                                                        |
| 90 | +       { | 
                                                        |
| 91 | + return $this->api->patch($this->url . '/campaigns/'.$campaign_guid, $params);  | 
                                                        |
| 92 | + }  | 
                                                        |
| 93 | 93 | |
| 94 | - /*  | 
                                                        |
| 94 | + /*  | 
                                                        |
| 95 | 95 | Get A Channel  | 
                                                        
| 96 | 96 | https://dev.bitly.com/v4/#operation/getChannel  | 
                                                        
| 97 | 97 | */  | 
                                                        
| 98 | - public function getChannel(string $channel_guid)  | 
                                                        |
| 99 | -      { | 
                                                        |
| 100 | - return $this->api->get($this->url . '/channels/'.$channel_guid);  | 
                                                        |
| 101 | - }  | 
                                                        |
| 98 | + public function getChannel(string $channel_guid)  | 
                                                        |
| 99 | +       { | 
                                                        |
| 100 | + return $this->api->get($this->url . '/channels/'.$channel_guid);  | 
                                                        |
| 101 | + }  | 
                                                        |
| 102 | 102 | |
| 103 | - /*  | 
                                                        |
| 103 | + /*  | 
                                                        |
| 104 | 104 | Update A Channel  | 
                                                        
| 105 | 105 | https://dev.bitly.com/v4/#operation/updateChannel  | 
                                                        
| 106 | 106 | */  | 
                                                        
| 107 | - public function updateChannel(string $channel_guid, array $params)  | 
                                                        |
| 108 | -      { | 
                                                        |
| 109 | - return $this->api->patch($this->url . '/channels/'.$channel_guid, $params);  | 
                                                        |
| 110 | - }  | 
                                                        |
| 107 | + public function updateChannel(string $channel_guid, array $params)  | 
                                                        |
| 108 | +       { | 
                                                        |
| 109 | + return $this->api->patch($this->url . '/channels/'.$channel_guid, $params);  | 
                                                        |
| 110 | + }  | 
                                                        |
| 111 | 111 | |
| 112 | 112 | }  | 
                                                        
@@ -31,7 +31,7 @@ discard block  | 
                                                    ||
| 31 | 31 | private $url;  | 
                                                        
| 32 | 32 | private $api;  | 
                                                        
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api)  | 
                                                        |
| 34 | + public function __construct(ApiInterface $api)  | 
                                                        |
| 35 | 35 |        { | 
                                                        
| 36 | 36 | $this->api = $api;  | 
                                                        
| 37 | 37 | $this->url = 'https://api-ssl.bitly.com/v4';  | 
                                                        
@@ -43,7 +43,7 @@ discard block  | 
                                                    ||
| 43 | 43 | */  | 
                                                        
| 44 | 44 | public function createChannel(array $params)  | 
                                                        
| 45 | 45 |        { | 
                                                        
| 46 | - return $this->api->post($this->url . '/channels', $params);  | 
                                                        |
| 46 | + return $this->api->post($this->url.'/channels', $params);  | 
                                                        |
| 47 | 47 | }  | 
                                                        
| 48 | 48 | |
| 49 | 49 | /*  | 
                                                        
@@ -52,7 +52,7 @@ discard block  | 
                                                    ||
| 52 | 52 | */  | 
                                                        
| 53 | 53 | public function getChannels(array $params)  | 
                                                        
| 54 | 54 |        { | 
                                                        
| 55 | - return $this->api->get($this->url . '/channels', $params);  | 
                                                        |
| 55 | + return $this->api->get($this->url.'/channels', $params);  | 
                                                        |
| 56 | 56 | }  | 
                                                        
| 57 | 57 | |
| 58 | 58 | /*  | 
                                                        
@@ -61,7 +61,7 @@ discard block  | 
                                                    ||
| 61 | 61 | */  | 
                                                        
| 62 | 62 | public function createCampaign(array $params)  | 
                                                        
| 63 | 63 |        { | 
                                                        
| 64 | - return $this->api->post($this->url . '/campaigns', $params);  | 
                                                        |
| 64 | + return $this->api->post($this->url.'/campaigns', $params);  | 
                                                        |
| 65 | 65 | }  | 
                                                        
| 66 | 66 | |
| 67 | 67 | /*  | 
                                                        
@@ -70,7 +70,7 @@ discard block  | 
                                                    ||
| 70 | 70 | */  | 
                                                        
| 71 | 71 | public function getCampaigns(array $params)  | 
                                                        
| 72 | 72 |        { | 
                                                        
| 73 | - return $this->api->get($this->url . '/campaigns', $params);  | 
                                                        |
| 73 | + return $this->api->get($this->url.'/campaigns', $params);  | 
                                                        |
| 74 | 74 | }  | 
                                                        
| 75 | 75 | |
| 76 | 76 | /*  | 
                                                        
@@ -79,7 +79,7 @@ discard block  | 
                                                    ||
| 79 | 79 | */  | 
                                                        
| 80 | 80 | public function getCampaign(string $campaign_guid)  | 
                                                        
| 81 | 81 |        { | 
                                                        
| 82 | - return $this->api->get($this->url . '/campaigns/'.$campaign_guid);  | 
                                                        |
| 82 | + return $this->api->get($this->url.'/campaigns/'.$campaign_guid);  | 
                                                        |
| 83 | 83 | }  | 
                                                        
| 84 | 84 | |
| 85 | 85 | /*  | 
                                                        
@@ -88,7 +88,7 @@ discard block  | 
                                                    ||
| 88 | 88 | */  | 
                                                        
| 89 | 89 | public function updateCampaign(string $campaign_guid, array $params)  | 
                                                        
| 90 | 90 |        { | 
                                                        
| 91 | - return $this->api->patch($this->url . '/campaigns/'.$campaign_guid, $params);  | 
                                                        |
| 91 | + return $this->api->patch($this->url.'/campaigns/'.$campaign_guid, $params);  | 
                                                        |
| 92 | 92 | }  | 
                                                        
| 93 | 93 | |
| 94 | 94 | /*  | 
                                                        
@@ -97,7 +97,7 @@ discard block  | 
                                                    ||
| 97 | 97 | */  | 
                                                        
| 98 | 98 | public function getChannel(string $channel_guid)  | 
                                                        
| 99 | 99 |        { | 
                                                        
| 100 | - return $this->api->get($this->url . '/channels/'.$channel_guid);  | 
                                                        |
| 100 | + return $this->api->get($this->url.'/channels/'.$channel_guid);  | 
                                                        |
| 101 | 101 | }  | 
                                                        
| 102 | 102 | |
| 103 | 103 | /*  | 
                                                        
@@ -106,7 +106,7 @@ discard block  | 
                                                    ||
| 106 | 106 | */  | 
                                                        
| 107 | 107 | public function updateChannel(string $channel_guid, array $params)  | 
                                                        
| 108 | 108 |        { | 
                                                        
| 109 | - return $this->api->patch($this->url . '/channels/'.$channel_guid, $params);  | 
                                                        |
| 109 | + return $this->api->patch($this->url.'/channels/'.$channel_guid, $params);  | 
                                                        |
| 110 | 110 | }  | 
                                                        
| 111 | 111 | |
| 112 | 112 | }  | 
                                                        
@@ -28,121 +28,121 @@  | 
                                                    ||
| 28 | 28 | |
| 29 | 29 |  class Group { | 
                                                        
| 30 | 30 | |
| 31 | - private $url;  | 
                                                        |
| 32 | - private $api;  | 
                                                        |
| 31 | + private $url;  | 
                                                        |
| 32 | + private $api;  | 
                                                        |
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api)  | 
                                                        |
| 35 | -      { | 
                                                        |
| 36 | - $this->api = $api;  | 
                                                        |
| 37 | - $this->url = 'https://api-ssl.bitly.com/v4/groups';  | 
                                                        |
| 38 | - }  | 
                                                        |
| 34 | + public function __construct (ApiInterface $api)  | 
                                                        |
| 35 | +       { | 
                                                        |
| 36 | + $this->api = $api;  | 
                                                        |
| 37 | + $this->url = 'https://api-ssl.bitly.com/v4/groups';  | 
                                                        |
| 38 | + }  | 
                                                        |
| 39 | 39 | |
| 40 | - /*  | 
                                                        |
| 40 | + /*  | 
                                                        |
| 41 | 41 | Retrieve Tags by Group  | 
                                                        
| 42 | 42 | https://dev.bitly.com/v4/#operation/getGroupTags  | 
                                                        
| 43 | 43 | */  | 
                                                        
| 44 | - public function getGroupTags(string $group_guid)  | 
                                                        |
| 45 | -      { | 
                                                        |
| 46 | - return $this->api->get($this->url . '/'.$group_guid.'/tags');  | 
                                                        |
| 47 | - }  | 
                                                        |
| 44 | + public function getGroupTags(string $group_guid)  | 
                                                        |
| 45 | +       { | 
                                                        |
| 46 | + return $this->api->get($this->url . '/'.$group_guid.'/tags');  | 
                                                        |
| 47 | + }  | 
                                                        |
| 48 | 48 | |
| 49 | - /*  | 
                                                        |
| 49 | + /*  | 
                                                        |
| 50 | 50 | Get Click Metrics for a Group by referring networks  | 
                                                        
| 51 | 51 | https://dev.bitly.com/v4/#operation/GetGroupMetricsByReferringNetworks  | 
                                                        
| 52 | 52 | */  | 
                                                        
| 53 | - public function getGroupMetricsByReferringNetworks(string $group_guid)  | 
                                                        |
| 54 | -      { | 
                                                        |
| 55 | - return $this->api->get($this->url . '/'.$group_guid.'/referring_networks');  | 
                                                        |
| 56 | - }  | 
                                                        |
| 53 | + public function getGroupMetricsByReferringNetworks(string $group_guid)  | 
                                                        |
| 54 | +       { | 
                                                        |
| 55 | + return $this->api->get($this->url . '/'.$group_guid.'/referring_networks');  | 
                                                        |
| 56 | + }  | 
                                                        |
| 57 | 57 | |
| 58 | - /*  | 
                                                        |
| 58 | + /*  | 
                                                        |
| 59 | 59 | Retrieve Group Shorten Counts  | 
                                                        
| 60 | 60 | https://dev.bitly.com/v4/#operation/getGroupShortenCounts  | 
                                                        
| 61 | 61 | */  | 
                                                        
| 62 | - public function getGroupShortenCounts(string $group_guid)  | 
                                                        |
| 63 | -      { | 
                                                        |
| 64 | - return $this->api->get($this->url . '/'.$group_guid.'/shorten_counts');  | 
                                                        |
| 65 | - }  | 
                                                        |
| 62 | + public function getGroupShortenCounts(string $group_guid)  | 
                                                        |
| 63 | +       { | 
                                                        |
| 64 | + return $this->api->get($this->url . '/'.$group_guid.'/shorten_counts');  | 
                                                        |
| 65 | + }  | 
                                                        |
| 66 | 66 | |
| 67 | - /*  | 
                                                        |
| 67 | + /*  | 
                                                        |
| 68 | 68 | Retrieve Groups  | 
                                                        
| 69 | 69 | https://dev.bitly.com/v4/#operation/getGroups  | 
                                                        
| 70 | 70 | */  | 
                                                        
| 71 | - public function getGroups(array $params = array())  | 
                                                        |
| 72 | -      { | 
                                                        |
| 73 | - return $this->api->get($this->url, $params);  | 
                                                        |
| 74 | - }  | 
                                                        |
| 71 | + public function getGroups(array $params = array())  | 
                                                        |
| 72 | +       { | 
                                                        |
| 73 | + return $this->api->get($this->url, $params);  | 
                                                        |
| 74 | + }  | 
                                                        |
| 75 | 75 | |
| 76 | - /*  | 
                                                        |
| 76 | + /*  | 
                                                        |
| 77 | 77 | Retrieve Group Preferences  | 
                                                        
| 78 | 78 | https://dev.bitly.com/v4/#operation/getGroupPreferences  | 
                                                        
| 79 | 79 | */  | 
                                                        
| 80 | - public function getGroupPreferences(string $group_guid)  | 
                                                        |
| 81 | -      { | 
                                                        |
| 82 | - return $this->api->get($this->url . '/'.$group_guid.'/preferences');  | 
                                                        |
| 83 | - }  | 
                                                        |
| 80 | + public function getGroupPreferences(string $group_guid)  | 
                                                        |
| 81 | +       { | 
                                                        |
| 82 | + return $this->api->get($this->url . '/'.$group_guid.'/preferences');  | 
                                                        |
| 83 | + }  | 
                                                        |
| 84 | 84 | |
| 85 | - /*  | 
                                                        |
| 85 | + /*  | 
                                                        |
| 86 | 86 | Update Group Preferences  | 
                                                        
| 87 | 87 | https://dev.bitly.com/v4/#operation/updateGroupPreferences  | 
                                                        
| 88 | 88 | */  | 
                                                        
| 89 | - public function updateGroupPreferences(string $group_guid, array $params)  | 
                                                        |
| 90 | -      { | 
                                                        |
| 91 | - return $this->api->patch($this->url . '/'.$group_guid.'/preferences', $params);  | 
                                                        |
| 92 | - }  | 
                                                        |
| 89 | + public function updateGroupPreferences(string $group_guid, array $params)  | 
                                                        |
| 90 | +       { | 
                                                        |
| 91 | + return $this->api->patch($this->url . '/'.$group_guid.'/preferences', $params);  | 
                                                        |
| 92 | + }  | 
                                                        |
| 93 | 93 | |
| 94 | - /*  | 
                                                        |
| 94 | + /*  | 
                                                        |
| 95 | 95 | Retrieve Bitlinks by Group  | 
                                                        
| 96 | 96 | https://dev.bitly.com/v4/#operation/getBitlinksByGroup  | 
                                                        
| 97 | 97 | */  | 
                                                        
| 98 | - public function getBitlinksByGroup(string $group_guid, array $params = array())  | 
                                                        |
| 99 | -      { | 
                                                        |
| 100 | - return $this->api->get($this->url . '/'.$group_guid.'/bitlinks', $params);  | 
                                                        |
| 101 | - }  | 
                                                        |
| 98 | + public function getBitlinksByGroup(string $group_guid, array $params = array())  | 
                                                        |
| 99 | +       { | 
                                                        |
| 100 | + return $this->api->get($this->url . '/'.$group_guid.'/bitlinks', $params);  | 
                                                        |
| 101 | + }  | 
                                                        |
| 102 | 102 | |
| 103 | - /*  | 
                                                        |
| 103 | + /*  | 
                                                        |
| 104 | 104 | Get Click Metrics for a Group by countries  | 
                                                        
| 105 | 105 | https://dev.bitly.com/v4/#operation/getGroupMetricsByCountries  | 
                                                        
| 106 | 106 | */  | 
                                                        
| 107 | - public function getGroupMetricsByCountries(string $group_guid)  | 
                                                        |
| 108 | -      { | 
                                                        |
| 109 | - return $this->api->get($this->url . '/'.$group_guid.'/countries');  | 
                                                        |
| 110 | - }  | 
                                                        |
| 107 | + public function getGroupMetricsByCountries(string $group_guid)  | 
                                                        |
| 108 | +       { | 
                                                        |
| 109 | + return $this->api->get($this->url . '/'.$group_guid.'/countries');  | 
                                                        |
| 110 | + }  | 
                                                        |
| 111 | 111 | |
| 112 | - /*  | 
                                                        |
| 112 | + /*  | 
                                                        |
| 113 | 113 | Retrieve Sorted Bitlinks for Group  | 
                                                        
| 114 | 114 | https://dev.bitly.com/v4/#operation/getSortedBitlinks  | 
                                                        
| 115 | 115 | */  | 
                                                        
| 116 | - public function getSortedBitlinks(string $group_guid, array $params = array(), string $sort = 'clicks')  | 
                                                        |
| 117 | -      { | 
                                                        |
| 118 | - return $this->api->get($this->url . '/'.$group_guid.'/bitlinks/'.$sort, $params);  | 
                                                        |
| 119 | - }  | 
                                                        |
| 116 | + public function getSortedBitlinks(string $group_guid, array $params = array(), string $sort = 'clicks')  | 
                                                        |
| 117 | +       { | 
                                                        |
| 118 | + return $this->api->get($this->url . '/'.$group_guid.'/bitlinks/'.$sort, $params);  | 
                                                        |
| 119 | + }  | 
                                                        |
| 120 | 120 | |
| 121 | - /*  | 
                                                        |
| 121 | + /*  | 
                                                        |
| 122 | 122 | Update a Group  | 
                                                        
| 123 | 123 | https://dev.bitly.com/v4/#operation/updateGroup  | 
                                                        
| 124 | 124 | */  | 
                                                        
| 125 | - public function updateGroup(string $group_guid, array $params)  | 
                                                        |
| 126 | -      { | 
                                                        |
| 127 | - return $this->api->patch($this->url . '/'.$group_guid, $params);  | 
                                                        |
| 128 | - }  | 
                                                        |
| 125 | + public function updateGroup(string $group_guid, array $params)  | 
                                                        |
| 126 | +       { | 
                                                        |
| 127 | + return $this->api->patch($this->url . '/'.$group_guid, $params);  | 
                                                        |
| 128 | + }  | 
                                                        |
| 129 | 129 | |
| 130 | - /*  | 
                                                        |
| 130 | + /*  | 
                                                        |
| 131 | 131 | Retrieve a Group  | 
                                                        
| 132 | 132 | https://dev.bitly.com/v4/#operation/getGroup  | 
                                                        
| 133 | 133 | */  | 
                                                        
| 134 | - public function getGroup(string $group_guid)  | 
                                                        |
| 135 | -      { | 
                                                        |
| 136 | - return $this->api->get($this->url . '/'.$group_guid);  | 
                                                        |
| 137 | - }  | 
                                                        |
| 134 | + public function getGroup(string $group_guid)  | 
                                                        |
| 135 | +       { | 
                                                        |
| 136 | + return $this->api->get($this->url . '/'.$group_guid);  | 
                                                        |
| 137 | + }  | 
                                                        |
| 138 | 138 | |
| 139 | - /*  | 
                                                        |
| 139 | + /*  | 
                                                        |
| 140 | 140 | Delete a Group  | 
                                                        
| 141 | 141 | https://dev.bitly.com/v4/#operation/deleteGroup  | 
                                                        
| 142 | 142 | */  | 
                                                        
| 143 | - public function deleteGroup(string $group_guid)  | 
                                                        |
| 144 | -      { | 
                                                        |
| 145 | - return $this->api->delete($this->url . '/'.$group_guid);  | 
                                                        |
| 146 | - }  | 
                                                        |
| 143 | + public function deleteGroup(string $group_guid)  | 
                                                        |
| 144 | +       { | 
                                                        |
| 145 | + return $this->api->delete($this->url . '/'.$group_guid);  | 
                                                        |
| 146 | + }  | 
                                                        |
| 147 | 147 | |
| 148 | 148 | }  | 
                                                        
@@ -31,7 +31,7 @@ discard block  | 
                                                    ||
| 31 | 31 | private $url;  | 
                                                        
| 32 | 32 | private $api;  | 
                                                        
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api)  | 
                                                        |
| 34 | + public function __construct(ApiInterface $api)  | 
                                                        |
| 35 | 35 |        { | 
                                                        
| 36 | 36 | $this->api = $api;  | 
                                                        
| 37 | 37 | $this->url = 'https://api-ssl.bitly.com/v4/groups';  | 
                                                        
@@ -43,7 +43,7 @@ discard block  | 
                                                    ||
| 43 | 43 | */  | 
                                                        
| 44 | 44 | public function getGroupTags(string $group_guid)  | 
                                                        
| 45 | 45 |        { | 
                                                        
| 46 | - return $this->api->get($this->url . '/'.$group_guid.'/tags');  | 
                                                        |
| 46 | + return $this->api->get($this->url.'/'.$group_guid.'/tags');  | 
                                                        |
| 47 | 47 | }  | 
                                                        
| 48 | 48 | |
| 49 | 49 | /*  | 
                                                        
@@ -52,7 +52,7 @@ discard block  | 
                                                    ||
| 52 | 52 | */  | 
                                                        
| 53 | 53 | public function getGroupMetricsByReferringNetworks(string $group_guid)  | 
                                                        
| 54 | 54 |        { | 
                                                        
| 55 | - return $this->api->get($this->url . '/'.$group_guid.'/referring_networks');  | 
                                                        |
| 55 | + return $this->api->get($this->url.'/'.$group_guid.'/referring_networks');  | 
                                                        |
| 56 | 56 | }  | 
                                                        
| 57 | 57 | |
| 58 | 58 | /*  | 
                                                        
@@ -61,7 +61,7 @@ discard block  | 
                                                    ||
| 61 | 61 | */  | 
                                                        
| 62 | 62 | public function getGroupShortenCounts(string $group_guid)  | 
                                                        
| 63 | 63 |        { | 
                                                        
| 64 | - return $this->api->get($this->url . '/'.$group_guid.'/shorten_counts');  | 
                                                        |
| 64 | + return $this->api->get($this->url.'/'.$group_guid.'/shorten_counts');  | 
                                                        |
| 65 | 65 | }  | 
                                                        
| 66 | 66 | |
| 67 | 67 | /*  | 
                                                        
@@ -79,7 +79,7 @@ discard block  | 
                                                    ||
| 79 | 79 | */  | 
                                                        
| 80 | 80 | public function getGroupPreferences(string $group_guid)  | 
                                                        
| 81 | 81 |        { | 
                                                        
| 82 | - return $this->api->get($this->url . '/'.$group_guid.'/preferences');  | 
                                                        |
| 82 | + return $this->api->get($this->url.'/'.$group_guid.'/preferences');  | 
                                                        |
| 83 | 83 | }  | 
                                                        
| 84 | 84 | |
| 85 | 85 | /*  | 
                                                        
@@ -88,7 +88,7 @@ discard block  | 
                                                    ||
| 88 | 88 | */  | 
                                                        
| 89 | 89 | public function updateGroupPreferences(string $group_guid, array $params)  | 
                                                        
| 90 | 90 |        { | 
                                                        
| 91 | - return $this->api->patch($this->url . '/'.$group_guid.'/preferences', $params);  | 
                                                        |
| 91 | + return $this->api->patch($this->url.'/'.$group_guid.'/preferences', $params);  | 
                                                        |
| 92 | 92 | }  | 
                                                        
| 93 | 93 | |
| 94 | 94 | /*  | 
                                                        
@@ -97,7 +97,7 @@ discard block  | 
                                                    ||
| 97 | 97 | */  | 
                                                        
| 98 | 98 | public function getBitlinksByGroup(string $group_guid, array $params = array())  | 
                                                        
| 99 | 99 |        { | 
                                                        
| 100 | - return $this->api->get($this->url . '/'.$group_guid.'/bitlinks', $params);  | 
                                                        |
| 100 | + return $this->api->get($this->url.'/'.$group_guid.'/bitlinks', $params);  | 
                                                        |
| 101 | 101 | }  | 
                                                        
| 102 | 102 | |
| 103 | 103 | /*  | 
                                                        
@@ -106,7 +106,7 @@ discard block  | 
                                                    ||
| 106 | 106 | */  | 
                                                        
| 107 | 107 | public function getGroupMetricsByCountries(string $group_guid)  | 
                                                        
| 108 | 108 |        { | 
                                                        
| 109 | - return $this->api->get($this->url . '/'.$group_guid.'/countries');  | 
                                                        |
| 109 | + return $this->api->get($this->url.'/'.$group_guid.'/countries');  | 
                                                        |
| 110 | 110 | }  | 
                                                        
| 111 | 111 | |
| 112 | 112 | /*  | 
                                                        
@@ -115,7 +115,7 @@ discard block  | 
                                                    ||
| 115 | 115 | */  | 
                                                        
| 116 | 116 | public function getSortedBitlinks(string $group_guid, array $params = array(), string $sort = 'clicks')  | 
                                                        
| 117 | 117 |        { | 
                                                        
| 118 | - return $this->api->get($this->url . '/'.$group_guid.'/bitlinks/'.$sort, $params);  | 
                                                        |
| 118 | + return $this->api->get($this->url.'/'.$group_guid.'/bitlinks/'.$sort, $params);  | 
                                                        |
| 119 | 119 | }  | 
                                                        
| 120 | 120 | |
| 121 | 121 | /*  | 
                                                        
@@ -124,7 +124,7 @@ discard block  | 
                                                    ||
| 124 | 124 | */  | 
                                                        
| 125 | 125 | public function updateGroup(string $group_guid, array $params)  | 
                                                        
| 126 | 126 |        { | 
                                                        
| 127 | - return $this->api->patch($this->url . '/'.$group_guid, $params);  | 
                                                        |
| 127 | + return $this->api->patch($this->url.'/'.$group_guid, $params);  | 
                                                        |
| 128 | 128 | }  | 
                                                        
| 129 | 129 | |
| 130 | 130 | /*  | 
                                                        
@@ -133,7 +133,7 @@ discard block  | 
                                                    ||
| 133 | 133 | */  | 
                                                        
| 134 | 134 | public function getGroup(string $group_guid)  | 
                                                        
| 135 | 135 |        { | 
                                                        
| 136 | - return $this->api->get($this->url . '/'.$group_guid);  | 
                                                        |
| 136 | + return $this->api->get($this->url.'/'.$group_guid);  | 
                                                        |
| 137 | 137 | }  | 
                                                        
| 138 | 138 | |
| 139 | 139 | /*  | 
                                                        
@@ -142,7 +142,7 @@ discard block  | 
                                                    ||
| 142 | 142 | */  | 
                                                        
| 143 | 143 | public function deleteGroup(string $group_guid)  | 
                                                        
| 144 | 144 |        { | 
                                                        
| 145 | - return $this->api->delete($this->url . '/'.$group_guid);  | 
                                                        |
| 145 | + return $this->api->delete($this->url.'/'.$group_guid);  | 
                                                        |
| 146 | 146 | }  | 
                                                        
| 147 | 147 | |
| 148 | 148 | }  |