Skip to content

Commit

Permalink
declare all instance variables on ObjectProperties class (#140)
Browse files Browse the repository at this point in the history
* declare variables in ObjectProperties to prevent 'property declared dynamically' warnings

* include optional fields in request

* "Default workspace" got renamed to "Production workspace"
  • Loading branch information
bverbeken authored Dec 2, 2024
1 parent 1cf9037 commit 5a9a47a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Events/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ private static function normalizeObjects($objectOrObjects): array
}
return array_map(function ($object) {
if ($object instanceof ObjectProperties) {
return $object;
return $object->toArray();
}
if (is_string($object)) {
return ["objectId" => $object];
Expand Down
28 changes: 28 additions & 0 deletions src/Events/ObjectProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ class ObjectProperties
* @var string
*/
public $objectId;
/**
* @var string
*/
public $ticketType;
/**
* @var int
*/
public $quantity;
/**
* @var array
*/
public $extraData;


public function __construct(string $objectId)
{
Expand All @@ -31,4 +44,19 @@ public function setExtraData(array $extraData): self
$this->extraData = $extraData;
return $this;
}

public function toArray()
{
$result = ["objectId" => $this->objectId];
if ($this->ticketType !== null) {
$result["ticketType"] = $this->ticketType;
}
if ($this->quantity !== null) {
$result["quantity"] = $this->quantity;
}
if($this->extraData !== null) {
$result["extraData"] = $this->extraData;
}
return $result;
}
}
2 changes: 1 addition & 1 deletion tests/Workspaces/ListActiveWorkspacesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function test()
return $workspace->name;
});

self::assertEquals(["ws3", "ws1", "Default workspace"], array_values($workspaceNames));
self::assertEquals(["ws3", "ws1", "Production workspace"], array_values($workspaceNames));
}

public function test_filter()
Expand Down
2 changes: 1 addition & 1 deletion tests/Workspaces/ListWorkspacesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function test()
return $workspace->name;
});

self::assertEquals(["ws3", "ws2", "ws1", "Default workspace"], array_values($workspaceNames));
self::assertEquals(["ws3", "ws2", "ws1", "Production workspace"], array_values($workspaceNames));
}

public function test_filter()
Expand Down

0 comments on commit 5a9a47a

Please sign in to comment.