Footer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 16 1
A __construct() 0 5 1
1
<?php
2
namespace MrPrompt\Celesc\Shipment\Partial;
3
4
use MrPrompt\ShipmentCommon\Base\Sequence;
5
use MrPrompt\ShipmentCommon\Type\Alphanumeric;
6
use MrPrompt\ShipmentCommon\Type\Numeric;
7
8
/**
9
 * File footer
10
 *
11
 * @author Thiago Paes <[email protected]>
12
 */
13
class Footer
14
{
15
    /**
16
     * Type of register
17
     *
18
     * @var string
19
     */
20
    const TYPE = 9;
21
22
    /**
23
     * Sequence number
24
     *
25
     * @var Sequence
26
     */
27
    private $sequence;
28
29
    /**
30
     * Total of new charges
31
     *
32
     * @var int
33
     */
34
    private $total;
35
36
    /**
37
     * Sum of new charges
38
     *
39
     * @var int
40
     */
41
    private $sum;
42
43
    /**
44
     * @param int $totalCharges
45
     * @param int $sumCharges
46
     * @param Sequence $sequence
47
     */
48 1
    public function __construct($totalCharges = 0, $sumCharges = 0, Sequence $sequence)
49
    {
50 1
        $this->total    = $totalCharges;
51 1
        $this->sum      = $sumCharges;
52 1
        $this->sequence = $sequence;
53 1
    }
54
55
    /**
56
     * Render footer line
57
     *
58
     * @return string
59
     */
60 1
    public function render()
61
    {
62
        // register code
63 1
        $result = self::TYPE;
64
65
        // sum of charges values
66 1
        $result .= str_pad(str_replace('.',  '', $this->sum), 11, Numeric::FILL, Numeric::ALIGN);
67
68
        // whitespace
69 1
        $result .= str_pad(' ', 132, Alphanumeric::FILL, Alphanumeric::ALIGN);
70
71
        // sequence line
72 1
        $result .= str_pad($this->sequence->getValue(), 6, Numeric::FILL, Numeric::ALIGN);
73
74
        // resulting...
75 1
        return $result;
76
    }
77
}
78