BearerRequestTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 59
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setCardVerificationValue() 0 6 1
A getBearerParameters() 0 13 2
1
<?php
2
3
/*
4
 * This file is part of the Nexylan packages.
5
 *
6
 * (c) Nexylan SAS <[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
namespace Nexy\PayboxDirect\Request;
13
14
use Symfony\Component\Validator\Constraints as Assert;
15
16
/**
17
 * @author Sullivan Senechal <[email protected]>
18
 */
19
trait BearerRequestTrait
20
{
21
    /**
22
     * Card number or reference.
23
     *
24
     * @var string
25
     *
26
     * @Assert\Type("string")
27
     * @Assert\Length(min=1, max=19)
28
     */
29
    private $bearer;
30
31
    /**
32
     * @var string
33
     *
34
     * @Assert\Type("string")
35
     * @Assert\Length(min=4, max=4)
36
     * @Assert\Regex("/[0-9]+/")
37
     */
38
    private $validityDate;
39
40
    /**
41
     * @var string|null
42
     *
43
     * @Assert\Type("string")
44
     * @Assert\Length(min=3, max=4)
45
     * @Assert\Regex("/[0-9]+/")
46
     */
47
    private $cardVerificationValue = null;
48
49
    /**
50
     * @param string|null $cardVerificationValue
51
     *
52
     * @return $this
53
     */
54
    public function setCardVerificationValue($cardVerificationValue = null)
55
    {
56
        $this->cardVerificationValue = $cardVerificationValue;
57
58
        return $this;
59
    }
60
61
    /**
62
     * @return array
63
     */
64
    private function getBearerParameters()
65
    {
66
        $parameters = [
67
            'PORTEUR' => $this->bearer,
68
            'DATEVAL' => $this->validityDate,
69
        ];
70
71
        if (null !== $this->cardVerificationValue) {
72
            $parameters['CVV'] = $this->cardVerificationValue;
73
        }
74
75
        return $parameters;
76
    }
77
}
78