Passed
Push — main ( 7189b9...23cbe4 )
by Vasil
03:17
created

Payer::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VasilDakov\Speedy\Service\Shipment;
6
7
use JMS\Serializer\Annotation as Serializer;
8
9
/**
10
 * Class Payer
11
 *
12
 * @Serializer\AccessType("public_method")
13
 * @author Valentin Valkanov <[email protected]>
14
 * @copyright
15
 * @version
16
 */
17
class Payer
18
{
19
    /**
20
     * array
21
     */
22
    public const OPTIONS = [
23
        'SENDER',
24
        'RECIPIENT',
25
        'THIRD_PARTY'
26
    ];
27
28
    /**
29
     * @var string
30
     * @Serializer\Type("string")
31
     */
32
    private string $value;
33
34
    /**
35
     * @param string $value
36
     */
37 3
    public function __construct(string $value)
38
    {
39 3
        $this->setValue($value);
40
    }
41
42
    /**
43
     * @param string $value
44
     * @return void
45
     */
46 3
    public function setValue(string $value): void
47
    {
48 3
        if (! in_array($value, self::OPTIONS, true)) {
49 1
            throw new \InvalidArgumentException();
50
        }
51 2
        $this->value = $value;
52
    }
53
54
    /**
55
     * @return string
56
     */
57 1
    public function getValue(): string
58
    {
59 1
        return $this->value;
60
    }
61
62
    /**
63
     * @return string
64
     */
65 1
    public function __toString(): string
66
    {
67 1
        return $this->getValue();
68
    }
69
}
70