| Total Complexity | 4 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 12 | trait HasCurrencyRecord |
||
| 13 | { |
||
| 14 | protected $currencyObject; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @return Currency |
||
| 18 | */ |
||
| 19 | public function getCurrency() |
||
| 20 | { |
||
| 21 | if ($this->currencyObject === null) { |
||
| 22 | $this->initCurrency(); |
||
| 23 | } |
||
| 24 | |||
| 25 | return $this->currencyObject; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function initCurrency() |
||
| 29 | { |
||
| 30 | $this->currencyObject = $this->getCurrenciesManager()->getByCode($this->getCurrencyCode()); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @return \Nip\Records\AbstractModels\RecordManager|CurrenciesTrait |
||
| 35 | */ |
||
| 36 | public function getCurrenciesManager() |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | abstract public function getCurrencyCode(); |
||
| 45 | } |
||
| 46 |