OrderIdFormatter::format()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
namespace Paranoia\Formatter\Posnet;
3
4
use Paranoia\Exception\InvalidArgumentException;
5
use Paranoia\Formatter\FormatterInterface;
6
7
class OrderIdFormatter implements FormatterInterface
8
{
9
    const MAX_INPUT_LENGTH = 24;
10
11
    public function format($input)
12
    {
13
        if (strlen($input) > self::MAX_INPUT_LENGTH) {
14
            throw new InvalidArgumentException('Order ID can not contain more than 24 characters.');
15
        }
16
17
        return str_repeat('0', self::MAX_INPUT_LENGTH - strlen($input)) . $input;
18
    }
19
}
20