Completed
Push — master ( 5d18c7...cabcf3 )
by Hannes
16s queued 13s
created

FormattableTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
ccs 8
cts 10
cp 0.8
wmc 5
lcom 1
cbo 4

6 Methods

Rating   Name   Duplication   Size   Complexity  
getFormattable() 0 1 ?
A format() 0 4 1
A getNumber() 0 4 1
A __toString() 0 4 1
A get16() 0 4 1
A prettyprint() 0 4 1
1
<?php
2
3
namespace byrokrat\banking\Formatter;
4
5
use byrokrat\banking\AccountNumber;
6
7
/**
8
 * Helper trait that implements the AccountNumber formatting methods
9
 */
10
trait FormattableTrait
11
{
12
    abstract protected function getFormattable(): AccountNumber;
13
14 92
    public function format(FormatterInterface $formatter): string
15
    {
16 92
        return $formatter->format($this->getFormattable());
17
    }
18
19 91
    public function getNumber(): string
20
    {
21 91
        return $this->format(new StandardFormatter);
22
    }
23
24 86
    public function __toString(): string
25
    {
26 86
        return $this->getNumber();
27
    }
28
29 87
    public function get16(): string
30
    {
31 87
        return $this->format(new Generic16Formatter);
32
    }
33
34
    public function prettyprint(): string
35
    {
36
        return $this->format(new PrettyprintingFormatter);
37
    }
38
}
39