MerOrderNum   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 47
ccs 12
cts 12
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getParamName() 0 3 1
A __toString() 0 3 1
A getValue() 0 3 1
A validate() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the Pixidos package.
5
 *
6
 *  (c) Ondra Votava <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 *
11
 */
12
13
declare(strict_types=1);
14
15
namespace Pixidos\GPWebPay\Param;
16
17
use Pixidos\GPWebPay\Enum\Param;
18
use Pixidos\GPWebPay\Exceptions\InvalidArgumentException;
19
20
use function Pixidos\GPWebPay\assertIsInteger;
21
use function Pixidos\GPWebPay\assertMaxLength;
22
23
class MerOrderNum implements IParam
24
{
25
    /**
26
     * @var float|int|string
27
     */
28
    private $value;
29
30
    /**
31
     * OrderNumber constructor.
32
     *
33
     * @param int|float|string $value
34
     *
35
     * @throws InvalidArgumentException
36
     */
37 14
    public function __construct($value)
38
    {
39 14
        $this->validate($value);
40 10
        $this->value = $value;
41
    }
42
43
    /**
44
     * @return int|float|string
45
     */
46 1
    public function getValue()
47
    {
48 1
        return $this->value;
49
    }
50
51 14
    public function getParamName(): string
52
    {
53 14
        return Param::MERORDERNUM;
54
    }
55
56 9
    public function __toString(): string
57
    {
58 9
        return (string)$this->value;
59
    }
60
61
    /**
62
     * @param int|float|string $value
63
     *
64
     * @throws InvalidArgumentException
65
     */
66 14
    protected function validate($value): void
67
    {
68 14
        assertIsInteger($value, $this->getParamName());
69 11
        assertMaxLength($value, 30, $this->getParamName());
70
    }
71
}
72