ZeroPaddedInteger   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 17
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
1
<?php
2
3
namespace BestServedCold\PhalueObjects\Mathematical;
4
5
use BestServedCold\PhalueObjects\Mathematical;
6
7
/**
8
 * Class ZeroPaddedInteger
9
 *
10
 * @package   BestServedCold\PhalueObjects\Mathematical
11
 * @author    Adam Lewis <[email protected]>
12
 * @copyright Copyright (c) 2015 Best Served Cold Media Limited
13
 * @license   http://http://opensource.org/licenses/GPL-3.0 GPL License
14
 * @link      http://bestservedcold.com
15
 * @since     0.0.1-alpha
16
 * @version   0.0.2-alpha
17
 */
18
class ZeroPaddedInteger extends Mathematical
19
{
20
    /**
21
     * @param $value
22
     * @param int    $leading
23
     */
24 1
    public function __construct($value, $leading = 2)
25
    {
26 1
        parent::__construct(
27 1
            str_pad(
28 1
                $value,
29 1
                strlen((string) $value) + $leading,
30 1
                "0",
31 1
                STR_PAD_LEFT)
32 1
        );
33 1
    }
34
}
35