Skip to content

Commit 87c696a

Browse files
author
Matt Humphrey
committed
CS in HttpClient dir
1 parent e97e4cc commit 87c696a

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

lib/Gitlab/HttpClient/HttpClient.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?php
2-
3-
namespace Gitlab\HttpClient;
1+
<?php namespace Gitlab\HttpClient;
42

53
use Buzz\Client\ClientInterface;
64
use Buzz\Listener\ListenerInterface;
@@ -15,6 +13,7 @@
1513
* Performs requests on Gitlab API. API documentation should be self-explanatory.
1614
*
1715
* @author Joseph Bielawski <stloyd@gmail.com>
16+
* @author Matt Humphrey <matt@m4tt.co>
1817
*/
1918
class HttpClient implements HttpClientInterface
2019
{
@@ -26,18 +25,28 @@ class HttpClient implements HttpClientInterface
2625
'timeout' => 10,
2726
);
2827

29-
protected $base_url = null;
28+
/**
29+
* @var string
30+
*/
31+
protected $baseUrl;
3032

3133
/**
32-
* @var array
34+
* @var ListenerInterface[]
3335
*/
3436
protected $listeners = array();
3537
/**
3638
* @var array
3739
*/
3840
protected $headers = array();
3941

42+
/**
43+
* @var Response
44+
*/
4045
private $lastResponse;
46+
47+
/**
48+
* @var Request
49+
*/
4150
private $lastRequest;
4251

4352
/**
@@ -46,9 +55,9 @@ class HttpClient implements HttpClientInterface
4655
*/
4756
public function __construct($baseUrl, array $options, ClientInterface $client)
4857
{
49-
$this->base_url = $baseUrl;
50-
$this->options = array_merge($this->options, $options);
51-
$this->client = $client;
58+
$this->baseUrl = $baseUrl;
59+
$this->options = array_merge($this->options, $options);
60+
$this->client = $client;
5261

5362
$this->addListener(new ErrorListener($this->options));
5463

@@ -136,7 +145,7 @@ public function put($path, array $parameters = array(), array $headers = array()
136145
*/
137146
public function request($path, array $parameters = array(), $httpMethod = 'GET', array $headers = array())
138147
{
139-
$path = trim($this->base_url.$path, '/');
148+
$path = trim($this->baseUrl.$path, '/');
140149

141150
$request = $this->createRequest($httpMethod, $path);
142151
$request->addHeaders($headers);
@@ -190,7 +199,6 @@ public function getLastResponse()
190199
/**
191200
* @param string $httpMethod
192201
* @param string $url
193-
*
194202
* @return Request
195203
*/
196204
private function createRequest($httpMethod, $url)

lib/Gitlab/HttpClient/HttpClientInterface.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
<?php
2-
3-
namespace Gitlab\HttpClient;
1+
<?php namespace Gitlab\HttpClient;
42

53
use Gitlab\Exception\InvalidArgumentException;
64

75
/**
86
* Performs requests on Gitlab API. API documentation should be self-explanatory.
97
*
108
* @author Joseph Bielawski <stloyd@gmail.com>
9+
* @author Matt Humphrey <matt@m4tt.co>
1110
*/
1211
interface HttpClientInterface
1312
{

lib/Gitlab/HttpClient/Listener/AuthListener.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?php
2-
3-
namespace Gitlab\HttpClient\Listener;
1+
<?php namespace Gitlab\HttpClient\Listener;
42

53
use Gitlab\Client;
64
use Gitlab\Exception\InvalidArgumentException;

lib/Gitlab/HttpClient/Listener/ErrorListener.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?php
2-
3-
namespace Gitlab\HttpClient\Listener;
1+
<?php namespace Gitlab\HttpClient\Listener;
42

53
use Buzz\Listener\ListenerInterface;
64
use Buzz\Message\MessageInterface;

lib/Gitlab/HttpClient/Message/Request.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?php
2-
3-
namespace Gitlab\HttpClient\Message;
1+
<?php namespace Gitlab\HttpClient\Message;
42

53
use Buzz\Message\Request as BaseRequest;
64

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?php
2-
3-
namespace Gitlab\HttpClient\Message;
1+
<?php namespace Gitlab\HttpClient\Message;
42

53
use Buzz\Message\Response as BaseResponse;
64

@@ -12,16 +10,17 @@ class Response extends BaseResponse
1210
public function getContent()
1311
{
1412
$response = parent::getContent();
15-
if ($this->getHeader("Content-Type") === "application/json") {
13+
14+
if ($this->getHeader('Content-Type') === 'application/json') {
1615
$content = json_decode($response, true);
1716

1817
if (JSON_ERROR_NONE !== json_last_error()) {
1918
return $response;
2019
}
2120

2221
return $content;
23-
} else {
24-
return $response;
2522
}
23+
24+
return $response;
2625
}
2726
}

0 commit comments

Comments
 (0)