Skip to content

Commit 2eff055

Browse files
committed
Cleanup and extraneous code removal
- Removing "Collection" concept entirely - Removing "AbstractCollection" class - Removing "AbstractOptions" class - Removing "ConsulHttpParamContainerTrait" trait - Removing "Logger" system, wasn't used and we bubble up errors anyway - "Request::headers" and "Request::params" are now instances of "Values" - "Values" closely mimics go's URI.Query property, albeit without any encoding options.
1 parent 0f20497 commit 2eff055

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1480
-2547
lines changed

composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
],
1818
"require": {
1919
"php": ">=5.6.0",
20-
"psr/log": "1.0.*",
2120
"guzzlehttp/psr7": "1.4.*",
2221
"php-http/client-implementation": "@stable"
2322
},

src/ACL/ACLClient.php

+29-28
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
* Class ACLClient
2626
* @package DCarbone\PHPConsulAPI\ACL
2727
*/
28-
class ACLClient extends AbstractClient
29-
{
28+
class ACLClient extends AbstractClient {
3029
/**
3130
* @param \DCarbone\PHPConsulAPI\ACL\ACLEntry $acl
3231
* @param \DCarbone\PHPConsulAPI\WriteOptions|null $writeOptions
@@ -36,21 +35,22 @@ class ACLClient extends AbstractClient
3635
* @type \DCarbone\PHPConsulAPI\Error|null error, if any
3736
* )
3837
*/
39-
public function create(ACLEntry $acl, WriteOptions $writeOptions = null)
40-
{
38+
public function create(ACLEntry $acl, WriteOptions $writeOptions = null) {
4139
$r = new Request('put', 'v1/acl/create', $this->c, $acl);
4240
$r->setWriteOptions($writeOptions);
4341

4442
/** @var \Psr\Http\Message\ResponseInterface $response */
4543
list($duration, $response, $err) = $this->requireOK($this->doRequest($r));
46-
if (null !== $err)
44+
if (null !== $err) {
4745
return ['', null, $err];
46+
}
4847

4948
$wm = $this->buildWriteMeta($duration);
5049

5150
list($data, $err) = $this->decodeBody($response->getBody());
52-
if (null !== $err)
51+
if (null !== $err) {
5352
return ['', $wm, $err];
53+
}
5454

5555
return [$data, $wm, null];
5656
}
@@ -63,15 +63,15 @@ public function create(ACLEntry $acl, WriteOptions $writeOptions = null)
6363
* @type \DCarbone\PHPConsulAPI\Error|null error, if any
6464
* )
6565
*/
66-
public function update(ACLEntry $acl, WriteOptions $writeOptions = null)
67-
{
66+
public function update(ACLEntry $acl, WriteOptions $writeOptions = null) {
6867
$r = new Request('PUT', 'v1/acl/update', $this->c, $acl);
6968
$r->setWriteOptions($writeOptions);
7069

7170
list($duration, $_, $err) = $this->requireOK($this->doRequest($r));
7271

73-
if (null !== $err)
72+
if (null !== $err) {
7473
return [null, $err];
74+
}
7575

7676
return [$this->buildWriteMeta($duration), null];
7777
}
@@ -84,15 +84,15 @@ public function update(ACLEntry $acl, WriteOptions $writeOptions = null)
8484
* @type \DCarbone\PHPConsulAPI\Error|null error, if any
8585
* )
8686
*/
87-
public function destroy($id, WriteOptions $writeOptions = null)
88-
{
87+
public function destroy($id, WriteOptions $writeOptions = null) {
8988
$r = new Request('PUT', sprintf('v1/acl/destroy/%s', $id), $this->c);
9089
$r->setWriteOptions($writeOptions);
9190

9291
list($duration, $_, $err) = $this->requireOK($this->doRequest($r));
9392

94-
if (null !== $err)
93+
if (null !== $err) {
9594
return [null, $err];
95+
}
9696

9797
return [$this->buildWriteMeta($duration), null];
9898
}
@@ -106,21 +106,22 @@ public function destroy($id, WriteOptions $writeOptions = null)
106106
* @type \DCarbone\PHPConsulAPI\Error|null error, if any
107107
* )
108108
*/
109-
public function cloneACL($id, WriteOptions $writeOptions = null)
110-
{
109+
public function cloneACL($id, WriteOptions $writeOptions = null) {
111110
$r = new Request('PUT', sprintf('v1/acl/clone/%s', $id), $this->c);
112111
$r->setWriteOptions($writeOptions);
113112

114113
/** @var \Psr\Http\Message\ResponseInterface $response */
115114
list($duration, $response, $err) = $this->requireOK($this->doRequest($r));
116-
if (null !== $err)
115+
if (null !== $err) {
117116
return ['', null, $err];
117+
}
118118

119119
$wm = $this->buildWriteMeta($duration);
120120

121121
list($data, $err) = $this->decodeBody($response->getBody());
122-
if (null !== $err)
122+
if (null !== $err) {
123123
return ['', $wm, $err];
124+
}
124125

125126
return [$data, $wm, null];
126127
}
@@ -134,25 +135,25 @@ public function cloneACL($id, WriteOptions $writeOptions = null)
134135
* @type \DCarbone\PHPConsulAPI\Error|null error, if any
135136
* )
136137
*/
137-
public function info($id, QueryOptions $queryOptions = null)
138-
{
138+
public function info($id, QueryOptions $queryOptions = null) {
139139
$r = new Request('GET', sprintf('v1/acl/info/%s', $id), $this->c);
140140
$r->setQueryOptions($queryOptions);
141141

142142
/** @var \Psr\Http\Message\ResponseInterface $response */
143143
list($duration, $response, $err) = $this->requireOK($this->doRequest($r));
144-
if (null !== $err)
144+
if (null !== $err) {
145145
return [null, null, $err];
146+
}
146147

147148
$qm = $this->buildQueryMeta($duration, $response, $r->getUri());
148149

149150
list($data, $err) = $this->decodeBody($response->getBody());
150-
if (null !== $err)
151+
if (null !== $err) {
151152
return [null, $qm, $err];
153+
}
152154

153155
$entries = [];
154-
foreach($data as $entry)
155-
{
156+
foreach ($data as $entry) {
156157
$entries[] = new ACLEntry($entry);
157158
}
158159

@@ -167,26 +168,26 @@ public function info($id, QueryOptions $queryOptions = null)
167168
* @type \DCarbone\PHPConsulAPI\Error|null error, if any
168169
* )
169170
*/
170-
public function listACLs(QueryOptions $queryOptions = null)
171-
{
171+
public function listACLs(QueryOptions $queryOptions = null) {
172172
$r = new Request('GET', 'v1/acl/list', $this->c);
173173
$r->setQueryOptions($queryOptions);
174174

175175
/** @var \Psr\Http\Message\ResponseInterface $response */
176176
list($duration, $response, $err) = $this->requireOK($this->doRequest($r));
177-
if (null !== $err)
177+
if (null !== $err) {
178178
return [null, null, $err];
179+
}
179180

180181
$qm = $this->buildQueryMeta($duration, $response, $r->getUri());
181182

182183

183184
list($data, $err) = $this->decodeBody($response->getBody());
184-
if (null !== $err)
185+
if (null !== $err) {
185186
return [null, $qm, $err];
187+
}
186188

187189
$entries = [];
188-
foreach($data as $entry)
189-
{
190+
foreach ($data as $entry) {
190191
$entries[] = new ACLEntry($entry);
191192
}
192193

src/ACL/ACLEntry.php

+13-26
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
* Class ACLEntry
2323
* @package DCarbone\PHPConsulAPI\ACL
2424
*/
25-
class ACLEntry extends AbstractModel
26-
{
25+
class ACLEntry extends AbstractModel {
2726
/** @var int */
2827
public $CreateIndex = 0;
2928
/** @var int */
@@ -40,96 +39,84 @@ class ACLEntry extends AbstractModel
4039
/**
4140
* @return int
4241
*/
43-
public function getCreateIndex()
44-
{
42+
public function getCreateIndex() {
4543
return $this->CreateIndex;
4644
}
4745

4846
/**
4947
* @param int $CreateIndex
5048
*/
51-
public function setCreateIndex($CreateIndex)
52-
{
49+
public function setCreateIndex($CreateIndex) {
5350
$this->CreateIndex = $CreateIndex;
5451
}
5552

5653
/**
5754
* @return int
5855
*/
59-
public function getModifyIndex()
60-
{
56+
public function getModifyIndex() {
6157
return $this->ModifyIndex;
6258
}
6359

6460
/**
6561
* @param int $ModifyIndex
6662
*/
67-
public function setModifyIndex($ModifyIndex)
68-
{
63+
public function setModifyIndex($ModifyIndex) {
6964
$this->ModifyIndex = $ModifyIndex;
7065
}
7166

7267
/**
7368
* @return string
7469
*/
75-
public function getID()
76-
{
70+
public function getID() {
7771
return $this->ID;
7872
}
7973

8074
/**
8175
* @param string $ID
8276
*/
83-
public function setID($ID)
84-
{
77+
public function setID($ID) {
8578
$this->ID = $ID;
8679
}
8780

8881
/**
8982
* @return string
9083
*/
91-
public function getName()
92-
{
84+
public function getName() {
9385
return $this->Name;
9486
}
9587

9688
/**
9789
* @param string $Name
9890
*/
99-
public function setName($Name)
100-
{
91+
public function setName($Name) {
10192
$this->Name = $Name;
10293
}
10394

10495
/**
10596
* @return string
10697
*/
107-
public function getType()
108-
{
98+
public function getType() {
10999
return $this->Type;
110100
}
111101

112102
/**
113103
* @param string $Type
114104
*/
115-
public function setType($Type)
116-
{
105+
public function setType($Type) {
117106
$this->Type = $Type;
118107
}
119108

120109
/**
121110
* @return string
122111
*/
123-
public function getRules()
124-
{
112+
public function getRules() {
125113
return $this->Rules;
126114
}
127115

128116
/**
129117
* @param string $Rules
130118
*/
131-
public function setRules($Rules)
132-
{
119+
public function setRules($Rules) {
133120
$this->Rules = $Rules;
134121
}
135122
}

0 commit comments

Comments
 (0)