-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Contributte\Invoice\Provider; | ||
|
||
use BadMethodCallException; | ||
use Contributte\Invoice\Data\Account; | ||
use LogicException; | ||
use Nette\Utils\Arrays; | ||
|
||
final class InvoiceAccountsProvider | ||
{ | ||
|
||
/** @var Account[] */ | ||
private array $accounts; | ||
|
||
/** | ||
* @param Account[] $accounts | ||
*/ | ||
public function __construct(array $accounts) | ||
{ | ||
if (!$accounts) { | ||
throw new BadMethodCallException('Accounts array cannot be empty.'); | ||
} | ||
|
||
$this->accounts = $accounts; | ||
} | ||
|
||
/** | ||
* @return Account[] | ||
*/ | ||
public function getAccounts(): array | ||
{ | ||
return $this->accounts; | ||
} | ||
|
||
public function getAccount(): Account | ||
{ | ||
return Arrays::first($this->accounts) ?? throw new LogicException('Unexpected error.'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Contributte\Invoice\Provider; | ||
|
||
use Contributte\Invoice\Data\ICompany; | ||
|
||
final class InvoiceCompanyProvider | ||
{ | ||
|
||
public function __construct( | ||
private ICompany $company | ||
) | ||
{ | ||
} | ||
|
||
public function getCompany(): ICompany | ||
{ | ||
return $this->company; | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.