Completed
Push — master ( c44a53...3a33b3 )
by Sergey
02:56
created
src/Api/Endpoints/Columns.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 
5 5
 class Columns extends CrudEndpoint
6 6
 {
7
-    /**
8
-     * @var string
9
-     */
10
-    protected $endpoint = 'columns';
7
+	/**
8
+	 * @var string
9
+	 */
10
+	protected $endpoint = 'columns';
11 11
 }
12 12
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/Endpoints/Tasks.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 
5 5
 class Tasks extends CrudEndpoint
6 6
 {
7
-    /**
8
-     * @var string
9
-     */
10
-    protected $endpoint = 'tasks';
7
+	/**
8
+	 * @var string
9
+	 */
10
+	protected $endpoint = 'tasks';
11 11
 }
12 12
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/Endpoints/Widgets.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -4,26 +4,26 @@
 block discarded – undo
4 4
 
5 5
 class Widgets extends CrudEndpoint
6 6
 {
7
-    /**
8
-     * @var string
9
-     */
10
-    protected $endpoint = 'widgets';
7
+	/**
8
+	 * @var string
9
+	 */
10
+	protected $endpoint = 'widgets';
11 11
 
12
-    /**
13
-     * @param string $itemId
14
-     * @param string|null $collectionId
15
-     * @return mixed
16
-     */
17
-    public function delete($itemId, $collectionId = null)
18
-    {
19
-        $attributes = $collectionId ? ['collectionId' => $collectionId] : [];
12
+	/**
13
+	 * @param string $itemId
14
+	 * @param string|null $collectionId
15
+	 * @return mixed
16
+	 */
17
+	public function delete($itemId, $collectionId = null)
18
+	{
19
+		$attributes = $collectionId ? ['collectionId' => $collectionId] : [];
20 20
 
21
-        return $this
22
-            ->getHttp()
23
-            ->delete(
24
-                $this->makeRequestUrl($itemId),
25
-                $attributes,
26
-                $this->getHeaders()
27
-            );
28
-    }
21
+		return $this
22
+			->getHttp()
23
+			->delete(
24
+				$this->makeRequestUrl($itemId),
25
+				$attributes,
26
+				$this->getHeaders()
27
+			);
28
+	}
29 29
 }
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/Endpoints/Organizations.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -5,31 +5,31 @@
 block discarded – undo
5 5
 
6 6
 class Organizations extends CrudEndpoint
7 7
 {
8
-    /**
9
-     * @var string
10
-     */
11
-    protected $endpoint = 'organizations';
8
+	/**
9
+	 * @var string
10
+	 */
11
+	protected $endpoint = 'organizations';
12 12
 
13
-    /**
14
-     * @param string $id
15
-     * @return array
16
-     */
17
-    public function getById($id)
18
-    {
19
-        $this->headers['organizationId'] = $id;
13
+	/**
14
+	 * @param string $id
15
+	 * @return array
16
+	 */
17
+	public function getById($id)
18
+	{
19
+		$this->headers['organizationId'] = $id;
20 20
 
21
-        return parent::getById($id);
22
-    }
21
+		return parent::getById($id);
22
+	}
23 23
 
24
-    /**
25
-     * @param string $itemId
26
-     * @param array $attributes
27
-     * @return mixed
28
-     */
29
-    public function update($itemId, array $attributes)
30
-    {
31
-        $this->headers['organizationId'] = $itemId;
24
+	/**
25
+	 * @param string $itemId
26
+	 * @param array $attributes
27
+	 * @return mixed
28
+	 */
29
+	public function update($itemId, array $attributes)
30
+	{
31
+		$this->headers['organizationId'] = $itemId;
32 32
 
33
-        return parent::update($itemId, $attributes);
34
-    }
33
+		return parent::update($itemId, $attributes);
34
+	}
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
src/Contracts/HttpClient.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -4,46 +4,46 @@
 block discarded – undo
4 4
 
5 5
 interface HttpClient
6 6
 {
7
-    /**
8
-     * @param $uri
9
-     * @param array $params
10
-     * @param array $headers
11
-     * @return array
12
-     */
13
-    public function get($uri, $params = [], $headers = []);
7
+	/**
8
+	 * @param $uri
9
+	 * @param array $params
10
+	 * @param array $headers
11
+	 * @return array
12
+	 */
13
+	public function get($uri, $params = [], $headers = []);
14 14
 
15
-    /**
16
-     * @param string $uri
17
-     * @param array $body
18
-     * @param array $headers
19
-     * @return array
20
-     */
21
-    public function post($uri, $body = [], $headers = []);
15
+	/**
16
+	 * @param string $uri
17
+	 * @param array $body
18
+	 * @param array $headers
19
+	 * @return array
20
+	 */
21
+	public function post($uri, $body = [], $headers = []);
22 22
 
23
-    /**
24
-     * @param string $uri
25
-     * @param array $body
26
-     * @param array $headers
27
-     * @return mixed
28
-     */
29
-    public function put($uri, $body = [], $headers = []);
23
+	/**
24
+	 * @param string $uri
25
+	 * @param array $body
26
+	 * @param array $headers
27
+	 * @return mixed
28
+	 */
29
+	public function put($uri, $body = [], $headers = []);
30 30
 
31
-    /**
32
-     * @param string $uri
33
-     * @param array $body
34
-     * @param array $headers
35
-     * @return mixed
36
-     */
37
-    public function delete($uri, $body = [], $headers = []);
31
+	/**
32
+	 * @param string $uri
33
+	 * @param array $body
34
+	 * @param array $headers
35
+	 * @return mixed
36
+	 */
37
+	public function delete($uri, $body = [], $headers = []);
38 38
 
39
-    /**
40
-     * @param string $url
41
-     * @return $this
42
-     */
43
-    public function setBaseUrl($url);
39
+	/**
40
+	 * @param string $url
41
+	 * @return $this
42
+	 */
43
+	public function setBaseUrl($url);
44 44
 
45
-    /**
46
-     * @return array
47
-     */
48
-    public function getResponseHeaders();
45
+	/**
46
+	 * @return array
47
+	 */
48
+	public function getResponseHeaders();
49 49
 }
50 50
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/Endpoints/Endpoint.php 1 patch
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -6,125 +6,125 @@
 block discarded – undo
6 6
 
7 7
 class Endpoint
8 8
 {
9
-    /**
10
-     * @var array
11
-     */
12
-    protected $rateLimitInfo;
13
-
14
-    /**
15
-     * @var array
16
-     */
17
-    protected $allowedMethods = [
18
-        'getById',
19
-        'getAll',
20
-        'create',
21
-        'update',
22
-        'delete',
23
-    ];
24
-
25
-    /**
26
-     * @var string
27
-     */
28
-    protected $endpoint;
29
-
30
-    /**
31
-     * @var array
32
-     */
33
-    protected $headers = [];
34
-
35
-    /**
36
-     * @var HttpClient
37
-     */
38
-    protected $http;
39
-
40
-    /**
41
-     * @var string
42
-     */
43
-    protected $organizationId;
44
-
45
-    /**
46
-     * @param HttpClient $http
47
-     */
48
-    public function __construct(HttpClient $http)
49
-    {
50
-        $this->http = $http;
51
-    }
52
-
53
-    /**
54
-     * @param string $verb
55
-     * @return string
56
-     */
57
-    public function makeRequestUrl($verb = '')
58
-    {
59
-        return "https://favro.com/api/v1/{$this->endpoint}/$verb";
60
-    }
61
-
62
-    /**
63
-     * @param string $method
64
-     * @return bool
65
-     */
66
-    public function isMethodAllowed($method)
67
-    {
68
-        return in_array($method, $this->allowedMethods);
69
-    }
70
-
71
-    /**
72
-     * @return HttpClient
73
-     */
74
-    public function getHttp()
75
-    {
76
-        return $this->http;
77
-    }
78
-
79
-    /**
80
-     * @param array $params
81
-     * @return array
82
-     */
83
-    public function getAll(array $params = [])
84
-    {
85
-        return $this
86
-            ->getHttp()
87
-            ->get(
88
-                $this->makeRequestUrl(),
89
-                $params,
90
-                $this->getHeaders()
91
-            );
92
-    }
93
-
94
-    /**
95
-     * @param string $id
96
-     * @return array
97
-     */
98
-    public function getById($id)
99
-    {
100
-        return $this
101
-            ->getHttp()
102
-            ->get(
103
-                $this->makeRequestUrl($id),
104
-                [],
105
-                $this->getHeaders()
106
-            );
107
-    }
108
-
109
-    /**
110
-     * @return array
111
-     */
112
-    protected function getHeaders()
113
-    {
114
-        return array_merge(
115
-            ['organizationId' => $this->organizationId],
116
-            $this->headers
117
-        );
118
-    }
119
-
120
-    /**
121
-     * @param string $organizationId
122
-     * @return $this
123
-     */
124
-    public function setOrganizationId($organizationId)
125
-    {
126
-        $this->organizationId = $organizationId;
127
-
128
-        return $this;
129
-    }
9
+	/**
10
+	 * @var array
11
+	 */
12
+	protected $rateLimitInfo;
13
+
14
+	/**
15
+	 * @var array
16
+	 */
17
+	protected $allowedMethods = [
18
+		'getById',
19
+		'getAll',
20
+		'create',
21
+		'update',
22
+		'delete',
23
+	];
24
+
25
+	/**
26
+	 * @var string
27
+	 */
28
+	protected $endpoint;
29
+
30
+	/**
31
+	 * @var array
32
+	 */
33
+	protected $headers = [];
34
+
35
+	/**
36
+	 * @var HttpClient
37
+	 */
38
+	protected $http;
39
+
40
+	/**
41
+	 * @var string
42
+	 */
43
+	protected $organizationId;
44
+
45
+	/**
46
+	 * @param HttpClient $http
47
+	 */
48
+	public function __construct(HttpClient $http)
49
+	{
50
+		$this->http = $http;
51
+	}
52
+
53
+	/**
54
+	 * @param string $verb
55
+	 * @return string
56
+	 */
57
+	public function makeRequestUrl($verb = '')
58
+	{
59
+		return "https://favro.com/api/v1/{$this->endpoint}/$verb";
60
+	}
61
+
62
+	/**
63
+	 * @param string $method
64
+	 * @return bool
65
+	 */
66
+	public function isMethodAllowed($method)
67
+	{
68
+		return in_array($method, $this->allowedMethods);
69
+	}
70
+
71
+	/**
72
+	 * @return HttpClient
73
+	 */
74
+	public function getHttp()
75
+	{
76
+		return $this->http;
77
+	}
78
+
79
+	/**
80
+	 * @param array $params
81
+	 * @return array
82
+	 */
83
+	public function getAll(array $params = [])
84
+	{
85
+		return $this
86
+			->getHttp()
87
+			->get(
88
+				$this->makeRequestUrl(),
89
+				$params,
90
+				$this->getHeaders()
91
+			);
92
+	}
93
+
94
+	/**
95
+	 * @param string $id
96
+	 * @return array
97
+	 */
98
+	public function getById($id)
99
+	{
100
+		return $this
101
+			->getHttp()
102
+			->get(
103
+				$this->makeRequestUrl($id),
104
+				[],
105
+				$this->getHeaders()
106
+			);
107
+	}
108
+
109
+	/**
110
+	 * @return array
111
+	 */
112
+	protected function getHeaders()
113
+	{
114
+		return array_merge(
115
+			['organizationId' => $this->organizationId],
116
+			$this->headers
117
+		);
118
+	}
119
+
120
+	/**
121
+	 * @param string $organizationId
122
+	 * @return $this
123
+	 */
124
+	public function setOrganizationId($organizationId)
125
+	{
126
+		$this->organizationId = $organizationId;
127
+
128
+		return $this;
129
+	}
130 130
 }
131 131
\ No newline at end of file
Please login to merge, or discard this patch.
src/GuzzleHttpClient.php 1 patch
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -8,129 +8,129 @@
 block discarded – undo
8 8
 
9 9
 class GuzzleHttpClient implements HttpClient
10 10
 {
11
-    /**
12
-     * @var ClientInterface
13
-     */
14
-    protected $client;
15
-
16
-    /**
17
-     * @var array
18
-     */
19
-    protected $responseHeaders;
20
-
21
-    /**
22
-     * @param ClientInterface $client
23
-     */
24
-    public function __construct(ClientInterface $client)
25
-    {
26
-        $this->client = $client;
27
-    }
28
-
29
-    /**
30
-     * @param string $uri
31
-     * @param array $params
32
-     * @param array $headers
33
-     * @return string
34
-     */
35
-    public function get($uri, $params = [], $headers = [])
36
-    {
37
-        if (!empty($params)) {
38
-            $uri .= '?' . http_build_query($params);
39
-        }
40
-
41
-        $response = $this
42
-            ->client
43
-            ->get($uri, ['headers' => $headers]);
44
-
45
-        return $this->parseResponse($response);
46
-    }
47
-
48
-    /**
49
-     * @param string $uri
50
-     * @param array $body
51
-     * @param array $headers
52
-     * @return string
53
-     */
54
-    public function post($uri, $body = [], $headers = [])
55
-    {
56
-        $response = $this
57
-            ->client
58
-            ->post(
59
-                $uri, [
60
-                    'headers'     => $headers,
61
-                    'form_params' => $body,
62
-                ]
63
-            );
64
-
65
-        return $this->parseResponse($response);
66
-    }
67
-
68
-    /**
69
-     * @param string $uri
70
-     * @param array $body
71
-     * @param array $headers
72
-     * @return mixed
73
-     */
74
-    public function put($uri, $body = [], $headers = [])
75
-    {
76
-        $response = $this
77
-            ->client
78
-            ->put(
79
-                $uri, [
80
-                    'headers'     => $headers,
81
-                    'form_params' => $body,
82
-                ]
83
-            );
84
-
85
-        return $this->parseResponse($response);
86
-    }
87
-
88
-    /**
89
-     * @param string $uri
90
-     * @param array $body
91
-     * @param array $headers
92
-     * @return mixed
93
-     */
94
-    public function delete($uri, $body = [], $headers = [])
95
-    {
96
-        $response = $this
97
-            ->client
98
-            ->delete($uri, [
99
-                'headers'     => $headers,
100
-                'form_params' => $body,
101
-            ]);
102
-
103
-        return $this->parseResponse($response);
104
-    }
105
-
106
-    /**
107
-     * @param string $url
108
-     * @return $this
109
-     */
110
-    public function setBaseUrl($url)
111
-    {
112
-        $this->client->setBaseUrl($url);
113
-        return $this;
114
-    }
115
-
116
-    /**
117
-     * @param ResponseInterface $response
118
-     * @return array|null
119
-     */
120
-    protected function parseResponse(ResponseInterface $response)
121
-    {
122
-        $responseContents = $response->getBody()->getContents();
123
-
124
-        $this->responseHeaders = $response->getHeaders();
125
-
126
-        return json_decode($responseContents, true);
127
-    }
128
-
129
-    /**
130
-     * @return array
131
-     */
132
-    public function getResponseHeaders()
133
-    {
134
-        return $this->responseHeaders;
135
-    }
11
+	/**
12
+	 * @var ClientInterface
13
+	 */
14
+	protected $client;
15
+
16
+	/**
17
+	 * @var array
18
+	 */
19
+	protected $responseHeaders;
20
+
21
+	/**
22
+	 * @param ClientInterface $client
23
+	 */
24
+	public function __construct(ClientInterface $client)
25
+	{
26
+		$this->client = $client;
27
+	}
28
+
29
+	/**
30
+	 * @param string $uri
31
+	 * @param array $params
32
+	 * @param array $headers
33
+	 * @return string
34
+	 */
35
+	public function get($uri, $params = [], $headers = [])
36
+	{
37
+		if (!empty($params)) {
38
+			$uri .= '?' . http_build_query($params);
39
+		}
40
+
41
+		$response = $this
42
+			->client
43
+			->get($uri, ['headers' => $headers]);
44
+
45
+		return $this->parseResponse($response);
46
+	}
47
+
48
+	/**
49
+	 * @param string $uri
50
+	 * @param array $body
51
+	 * @param array $headers
52
+	 * @return string
53
+	 */
54
+	public function post($uri, $body = [], $headers = [])
55
+	{
56
+		$response = $this
57
+			->client
58
+			->post(
59
+				$uri, [
60
+					'headers'     => $headers,
61
+					'form_params' => $body,
62
+				]
63
+			);
64
+
65
+		return $this->parseResponse($response);
66
+	}
67
+
68
+	/**
69
+	 * @param string $uri
70
+	 * @param array $body
71
+	 * @param array $headers
72
+	 * @return mixed
73
+	 */
74
+	public function put($uri, $body = [], $headers = [])
75
+	{
76
+		$response = $this
77
+			->client
78
+			->put(
79
+				$uri, [
80
+					'headers'     => $headers,
81
+					'form_params' => $body,
82
+				]
83
+			);
84
+
85
+		return $this->parseResponse($response);
86
+	}
87
+
88
+	/**
89
+	 * @param string $uri
90
+	 * @param array $body
91
+	 * @param array $headers
92
+	 * @return mixed
93
+	 */
94
+	public function delete($uri, $body = [], $headers = [])
95
+	{
96
+		$response = $this
97
+			->client
98
+			->delete($uri, [
99
+				'headers'     => $headers,
100
+				'form_params' => $body,
101
+			]);
102
+
103
+		return $this->parseResponse($response);
104
+	}
105
+
106
+	/**
107
+	 * @param string $url
108
+	 * @return $this
109
+	 */
110
+	public function setBaseUrl($url)
111
+	{
112
+		$this->client->setBaseUrl($url);
113
+		return $this;
114
+	}
115
+
116
+	/**
117
+	 * @param ResponseInterface $response
118
+	 * @return array|null
119
+	 */
120
+	protected function parseResponse(ResponseInterface $response)
121
+	{
122
+		$responseContents = $response->getBody()->getContents();
123
+
124
+		$this->responseHeaders = $response->getHeaders();
125
+
126
+		return json_decode($responseContents, true);
127
+	}
128
+
129
+	/**
130
+	 * @return array
131
+	 */
132
+	public function getResponseHeaders()
133
+	{
134
+		return $this->responseHeaders;
135
+	}
136 136
 }
137 137
\ No newline at end of file
Please login to merge, or discard this patch.