Money   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A fromPence() 0 3 1
A inPence() 0 3 1
A fromPounds() 0 3 1
A __construct() 0 3 1
A inPounds() 0 3 1
A inPoundsAndPence() 0 3 1
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