Skip to content

Commit 14bc66e

Browse files
committed
more stuff
1 parent 48a9e91 commit 14bc66e

File tree

6 files changed

+74
-61
lines changed

6 files changed

+74
-61
lines changed

phpunit.xml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,35 @@
1616
<testsuite name="usage-config">
1717
<file>./tests/Usage/ConfigUsageTest.php</file>
1818
</testsuite>
19-
<!-- <testsuite name="usage-request">-->
20-
<!-- <file>./tests/Usage/RequestUsageTest.php</file>-->
21-
<!-- </testsuite>-->
19+
<testsuite name="usage-request">
20+
<file>./tests/Usage/RequestUsageTest.php</file>
21+
</testsuite>
2222

23-
<!-- <testsuite name="usage-acl">-->
24-
<!-- <directory>./tests/Usage/ACL</directory>-->
25-
<!-- </testsuite>-->
23+
<testsuite name="usage-acl">
24+
<directory>./tests/Usage/ACL</directory>
25+
</testsuite>
2626

2727
<testsuite name="usage-agent">
2828
<directory>./tests/Usage/Agent</directory>
2929
</testsuite>
30-
<!-- <testsuite name="usage-catalog">-->
31-
<!-- <directory>./tests/Usage/Catalog</directory>-->
32-
<!-- </testsuite>-->
33-
<!-- <testsuite name="usage-coordinate">-->
34-
<!-- <directory>./tests/Usage/Coordinate</directory>-->
35-
<!-- </testsuite>-->
36-
<!-- <testsuite name="usage-kv">-->
37-
<!-- <directory>./tests/Usage/KV</directory>-->
38-
<!-- </testsuite>-->
39-
<!-- <testsuite name="usage-operator">-->
40-
<!-- <directory>./tests/Usage/Operator</directory>-->
41-
<!-- </testsuite>-->
42-
<!-- <testsuite name="usage-session">-->
43-
<!-- <directory>./tests/Usage/Session</directory>-->
44-
<!-- </testsuite>-->
30+
<testsuite name="usage-catalog">
31+
<directory>./tests/Usage/Catalog</directory>
32+
</testsuite>
33+
<testsuite name="usage-coordinate">
34+
<directory>./tests/Usage/Coordinate</directory>
35+
</testsuite>
36+
<testsuite name="usage-kv">
37+
<directory>./tests/Usage/KV</directory>
38+
</testsuite>
39+
<testsuite name="usage-operator">
40+
<directory>./tests/Usage/Operator</directory>
41+
</testsuite>
42+
<testsuite name="usage-session">
43+
<directory>./tests/Usage/Session</directory>
44+
</testsuite>
4545

46-
<!-- <testsuite name="usage-random">-->
47-
<!-- <directory>./tests/Usage/Random</directory>-->
48-
<!-- </testsuite>-->
46+
<testsuite name="usage-random">
47+
<directory>./tests/Usage/Random</directory>
48+
</testsuite>
4949
</testsuites>
5050
</phpunit>

src/Coordinate/Coordinate.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ public function __construct(
6060
$this->Adjustment = $Adjustment;
6161
$this->Height = $Height;
6262
}
63-
if (null !== $data && [] !== $data) {
64-
self::jsonUnserialize((object)($data), $this);
65-
}
6663
}
6764

6865
/**

src/Coordinate/CoordinateClient.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
limitations under the License.
2121
*/
2222

23-
use DCarbone\Go\HTTP;
2423
use DCarbone\PHPConsulAPI\AbstractClient;
2524
use DCarbone\PHPConsulAPI\QueryOptions;
2625
use DCarbone\PHPConsulAPI\WriteOptions;

src/Coordinate/CoordinateDatacenterMap.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ public function __construct(
4040
$this->Datacenter = $Datacenter;
4141
$this->AreaID = $AreaID;
4242
$this->setCoordinates(...$Coordinates);
43-
if (null !== $data && [] !== $data) {
44-
self::jsonUnserialize((object)($data), $this);
45-
}
4643
}
4744

4845
public function getDatacenter(): string

src/Coordinate/CoordinateEntry.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ class CoordinateEntry extends AbstractModel
2929
public string $Partition;
3030
public null|Coordinate $Coord;
3131

32-
/**
33-
* @param array<string,mixed>|null $data
34-
*/
3532
public function __construct(
3633
string $Node = '',
3734
string $Segment = '',
@@ -42,9 +39,6 @@ public function __construct(
4239
$this->Segment = $Segment;
4340
$this->Partition = $Partition;
4441
$this->Coord = $Coord;
45-
if (null !== $data && [] !== $data) {
46-
self::jsonUnserialize((object)($data), $this);
47-
}
4842
}
4943

5044
public function getNode(): string

src/Event/UserEvent.php

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,33 @@
2424

2525
class UserEvent extends AbstractModel
2626
{
27-
public string $ID = '';
28-
public string $Name = '';
29-
public string $Payload = '';
30-
public string $NodeFilter = '';
31-
public string $ServiceFilter = '';
32-
public string $TagFilter = '';
33-
public int $Version = 0;
34-
public int $LTime = 0;
35-
36-
/**
37-
* UserEvent constructor.
38-
*
39-
* @param bool $_decodeValue
40-
*/
41-
public function __construct(array $data = [], bool $_decodeValue = false)
42-
{
43-
parent::__construct($data);
44-
if ($_decodeValue) {
45-
$dec = base64_decode($this->Payload, true);
46-
if (false === $dec) {
47-
throw new \InvalidArgumentException(sprintf('Could not base64 decode payload "%s"', $this->Payload));
48-
}
49-
$this->Payload = $dec;
50-
}
27+
public string $ID;
28+
public string $Name;
29+
public string $Payload;
30+
public string $NodeFilter;
31+
public string $ServiceFilter;
32+
public string $TagFilter;
33+
public int $Version;
34+
public int $LTime;
35+
36+
public function __construct(
37+
string $ID = '',
38+
string $Name = '',
39+
string $Payload = '',
40+
string $NodeFilter = '',
41+
string $ServiceFilter = '',
42+
string $TagFilter = '',
43+
int $Version = 0,
44+
int $LTime = 0
45+
) {
46+
$this->ID = $ID;
47+
$this->Name = $Name;
48+
$this->Payload = $Payload;
49+
$this->NodeFilter = $NodeFilter;
50+
$this->ServiceFilter = $ServiceFilter;
51+
$this->TagFilter = $TagFilter;
52+
$this->Version = $Version;
53+
$this->LTime = $LTime;
5154
}
5255

5356
public function getID(): string
@@ -89,4 +92,27 @@ public function getLTime(): int
8992
{
9093
return $this->LTime;
9194
}
95+
96+
public static function jsonUnserialize(\stdclass $decoded): self
97+
{
98+
$n = new self();
99+
foreach ($decoded as $k => $v) {
100+
$n->{$k} = $v;
101+
}
102+
return $n;
103+
}
104+
105+
public function jsonSerialize(): \stdClass
106+
{
107+
$out = $this->_startJsonSerialize();
108+
$out->ID = $this->ID;
109+
$out->Name = $this->Name;
110+
$out->Payload = $this->Payload;
111+
$out->NodeFilter = $this->NodeFilter;
112+
$out->ServiceFilter = $this->ServiceFilter;
113+
$out->TagFilter = $this->TagFilter;
114+
$out->Version = $this->Version;
115+
$out->LTime = $this->LTime;
116+
return $out;
117+
}
92118
}

0 commit comments

Comments
 (0)