Completed
Push — master ( 31cc79...dd89a0 )
by Manuel
05:17
created

AlternativeScheme::setParameter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sprain\SwissQrBill\DataGroup;
4
5
use Sprain\SwissQrBill\DataGroup\Interfaces\QrCodeData;
6
use Sprain\SwissQrBill\Validator\SelfValidatableTrait;
7
use Symfony\Component\Validator\Constraints as Assert;
8
use Symfony\Component\Validator\Mapping\ClassMetadata;
9
10
class AlternativeScheme implements QrCodeData
11
{
12
    use SelfValidatableTrait;
13
14
    /**
15
     * Parameter character chain of the alternative scheme
16
     * 
17
     * @var string
18
     */
19
    private $parameter;
20
21
    public function getParameter(): ?string
22
    {
23
        return $this->parameter;
24
    }
25
26
    public function setParameter(string $parameter) : self
27
    {
28
        $this->parameter = $parameter;
29
30
        return $this;
31
    }
32
33
    public function getQrCodeData() : array
34
    {
35
        return [
36
            $this->getParameter()
37
        ];
38
    }
39
40
    /**
41
     * Note that no real-life alternative schemes yet exist. Therefore validation is kept simple yet.
42
     * @link https://www.paymentstandards.ch/en/home/softwarepartner/qr-bill/alternative-schemes.html
43
     */
44
    public static function loadValidatorMetadata(ClassMetadata $metadata)
45
    {
46
        $metadata->addPropertyConstraints('parameter', [
47
            new Assert\NotBlank(),
48
            new Assert\Length([
49
                'max' => 100
50
            ])
51
        ]);
52
    }
53
}