Skip to content

Commit

Permalink
Merge branch 'hotfix/0.12.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aerendir committed Sep 27, 2024
2 parents aa5e292 + 56c7827 commit 4949f99
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/Manager/InvoicesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ public function setSubscription(SubscriptionInterface $subscription): self

public function addDrawer(string $name, InvoiceDrawerInterface $drawer): self
{
// If this is the default drawer
if ($this->defaultDrawer === $name) {
$this->defaultDrawer = $drawer;
}

$this->drawers[$name] = $drawer;

return $this;
Expand All @@ -98,20 +93,20 @@ public function drawInvoice(InvoiceInterface $invoice, string $drawer = null): a
public function getDrawer(string $drawer = null): InvoiceDrawerInterface
{
// If a Drawer were passed and it exists
if (null !== $drawer && \in_array($drawer, $this->drawers)) {
if (null !== $drawer && \in_array($drawer, array_keys($this->drawers))) {
// Use it
$drawer = $this->drawers[$drawer];
}

// If a drawer were not passed...
if (null === $drawer) {
// ... check for the existence of a default one and it doesn't exist...
if (null === $this->defaultDrawer) {
if (false === is_string($this->defaultDrawer)) {
// ... Throw an error
throw new \LogicException('To draw an Invoice you have to pass an InvoiceDrawerInterface drawer or either set a default drawer in the features set.');
}

$drawer = $this->defaultDrawer;
$drawer = $this->drawers[$this->defaultDrawer];
}

return $drawer;
Expand Down

0 comments on commit 4949f99

Please sign in to comment.