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

FormattableTrait::format()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 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