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

AlternativeScheme   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getQrCodeData() 0 4 1
A getParameter() 0 3 1
A setParameter() 0 5 1
A loadValidatorMetadata() 0 6 1
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
}