Last active
August 21, 2020 11:50
-
-
Save ralder/9ab0052c7f406a8511e007895dbc0aa8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
interface BalanceAccountTypeParamsAware | |
{ | |
/** @return AbstractTypeParameter[] */ | |
public function getTypeParams(): array; | |
} | |
class BalanceAccountType implemements BalanceAccountTypeParamsAware | |
{ | |
public function __construct(CurrencyParamType $currencyParamType, PayableParamType $payableParamType) | |
{...} | |
public function getTypeParams(): array | |
{ | |
return [$this->currencyParamType, $this->payableParamType]; | |
} | |
} | |
class CustomBalanceAccountTypeParams implements BalanceAccountTypeParamsAware | |
{...} | |
class BalanceAccountTypeCriteria | |
{ | |
public function __construct(BalanceAccountTypeParamsAware $typeParams) | |
{...} | |
public function get() | |
{ | |
$params = $this->typeParams->getTypeParams(); | |
... | |
} | |
} | |
// и тогда вызывать можно либо с кастомным набором параметров либо с жестким типом | |
// 1 | |
$typeParams = new CustomBalanceAccountTypeParams([ | |
CurrencyTypeParams::create('RUB'), | |
]); | |
$criteria = new BalanceAccountTypeCriteria($typeParams); | |
// 2 | |
$typeParams = new BalanceAccountType( | |
CurrencyTypeParams::create('RUB'), | |
PayableTypeParams::create('bonus') | |
); | |
$criteria = new BalanceAccountTypeCriteria($typeParams); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment