Skip to content

Commit

Permalink
Merge pull request #11 from Triggsy22/AssetPair-Rework
Browse files Browse the repository at this point in the history
Update AssetPair.php
  • Loading branch information
butschster authored May 6, 2024
2 parents ba4746b + 664f6e2 commit 50a8ae4
Show file tree
Hide file tree
Showing 2 changed files with 444 additions and 28 deletions.
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

0 comments on commit 50a8ae4

Please sign in to comment.