MoneyFormat   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 3
1
<?php
2
3
namespace ConferenceTools\Tickets\View\Helper;
4
5
use ConferenceTools\Tickets\Domain\ValueObject\Money;
6
use ConferenceTools\Tickets\Domain\ValueObject\Price;
7
use Zend\View\Helper\AbstractHelper;
8
9
class MoneyFormat extends AbstractHelper
10
{
11
    /**
12
     * @param Money $money
13
     * @param bool $useNet
14
     * @return string
15
     */
16
    public function __invoke($money, $useNet = false)
17
    {
18
        if ($money instanceof Price) {
0 ignored issues
show
introduced by
$money is never a sub-type of ConferenceTools\Tickets\Domain\ValueObject\Price.
Loading history...
19
            if ($useNet) {
20
                $money = $money->getNet();
21
            } else {
22
                $money = $money->getGross();
23
            }
24
        }
25
        $currencyFormat = $this->getView()->plugin('currencyFormat');
0 ignored issues
show
Bug introduced by
The method plugin() does not exist on Zend\View\Renderer\RendererInterface. It seems like you code against a sub-type of Zend\View\Renderer\RendererInterface such as Zend\View\Renderer\PhpRenderer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        $currencyFormat = $this->getView()->/** @scrutinizer ignore-call */ plugin('currencyFormat');
Loading history...
26
27
        return $currencyFormat($money->getAmount() / 100, $money->getCurrency());
28
    }
29
}
30