Currency   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toArray() 0 7 1
1
<?php
2
3
namespace NotificationChannels\WhatsApp\Component;
4
5
class Currency extends Component
6
{
7
    protected float $amount;
8
9
    /**
10
     * Currency code as defined in ISO 4217.
11
     */
12
    protected string $code;
13
14 3
    public function __construct(float $amount, string $code = 'EUR')
15
    {
16 3
        $this->amount = $amount;
17 3
        $this->code = $code;
18
    }
19
20 2
    public function toArray(): array
21
    {
22 2
        return [
23 2
            'type' => 'currency',
24 2
            'currency' => [
25 2
                'code' => $this->code,
26 2
                'amount_1000' => (int) ($this->amount * 1000),
27 2
            ],
28 2
        ];
29
    }
30
}
31