OrderIdFormatter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 11
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A format() 0 7 2
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