Conditions | 2 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
37 | public function getFormatted(Consumption $model, ?string $currentQuantity): string |
||
38 | { |
||
39 | if ($currentQuantity === null) { |
||
40 | return ''; |
||
41 | } |
||
42 | |||
43 | $consumption = new class($currentQuantity, $model->getAttributes()) extends Consumption |
||
44 | { |
||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | public $quantity; |
||
49 | |||
50 | public function __construct(string $quantity, array $config = []) |
||
51 | { |
||
52 | parent::__construct($config); |
||
53 | |||
54 | $this->quantity = $quantity; |
||
55 | } |
||
56 | }; |
||
57 | |||
58 | $formatter = $this->quantityFormatterFactory->forConsumption($consumption); |
||
59 | |||
60 | if ($formatter === null) { |
||
61 | return ''; |
||
62 | } |
||
63 | |||
64 | return $formatter->format(); |
||
65 | } |
||
68 |