Completed
Pull Request — master (#12)
by Sullivan
03:48 queued 01:40
created

AbstractRequest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 6
c 3
b 1
f 0
lcom 1
cbo 0
dl 0
loc 66
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setActivity() 0 6 1
A setDate() 0 6 1
A setShowCountry() 0 4 1
A getParameters() 0 13 3
1
<?php
2
3
namespace Nexy\PayboxDirect\Request;
4
5
use Nexy\PayboxDirect\Variable\Activity;
6
7
/**
8
 * @author Sullivan Senechal <[email protected]>
9
 */
10
abstract class AbstractRequest implements RequestInterface
11
{
12
    /**
13
     * @var int
14
     */
15
    private $activity = Activity::WEB_REQUEST;
16
17
    /**
18
     * @var \DateTime
19
     */
20
    private $date = null;
21
22
    /**
23
     * @var bool
24
     */
25
    private $showCountry = false;
26
27
    /**
28
     * @param int $activity
29
     *
30
     * @return $this
31
     */
32
    public function setActivity($activity)
33
    {
34
        $this->activity = $activity;
35
36
        return $this;
37
    }
38
39
    /**
40
     * @param \DateTime|null $date
41
     *
42
     * @return $this
43
     */
44
    final public function setDate(\DateTime $date = null)
45
    {
46
        $this->date = $date;
47
48
        return $this;
49
    }
50
51
    /**
52
     * @param bool $showCountry
53
     */
54
    public function setShowCountry($showCountry)
55
    {
56
        $this->showCountry = $showCountry;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function getParameters()
63
    {
64
        $parameters = [
65
            'ACTIVITE' => $this->activity,
66
            'DATEQ' => $this->date instanceof \DateTime ? $this->date->format('dmYHis') : null,
67
        ];
68
69
        if (true === $this->showCountry) {
70
            $parameters['PAYS'] = '';
71
        }
72
73
        return $parameters;
74
    }
75
}
76