Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

declare all instance variables on ObjectProperties class #140

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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