Money::fromPence()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php 
2
3
namespace App\Primitives;
4
5
class Money
6
{
7
    private $pence;
8
9
    private function __construct($pence)
10
    {
11
        $this->pence = (integer) $pence;
12
    }
13
14
    public static function fromPounds($pounds)
15
    {
16
        return new static($pounds * 100);
17
    }
18
19
    public static function fromPence($pence)
20
    {
21
        return new static($pence);
22
    }
23
24
    public function inPence()
25
    {
26
        return (string) $this->pence;
27
    }
28
29
    public function inPounds()
30
    {
31
        return (string) ($this->pence / 100);
32
    }
33
34
    public function inPoundsAndPence()
35
    {
36
        return number_format($this->pence / 100, 2);
37
    }
38
}
39