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

Update AssetPair.php #11

Merged
merged 4 commits into from
May 6, 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
28 changes: 23 additions & 5 deletions src/ValueObjects/AssetPair.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@

class AssetPair
{
/**
* @param string $asset1
* @param string|null $asset2
* @param string[] $assets
*/
public function __construct(
private string $asset1,
private string $asset2
private ?string $asset2 = null,
private array $assets = [],
)
{
}
Expand All @@ -21,20 +27,32 @@ public function getAsset1(): string
}

/**
* @return string
* @return ?string
*/
public function getAsset2(): string
public function getAsset2(): ?string
{
return $this->asset2;
}

/**
* @return string[]
*/
public function getAssets(): array
{
return $this->assets;
}

final public function equals(self $pair): bool
{
return (string)$this === (string)$pair;
}

public function __toString(): string
{
return sprintf('%s,%s', $this->asset1, $this->asset2);
$assets = [$this->asset1];
if($this->asset2 !== null)
$assets[] = $this->asset2;

return implode(',', array_merge($assets,$this->assets));
}
}
}
Loading
Loading