Passed
Push — master ( 1167f2...7f7b1f )
by Manuel
01:41
created

Parameter::classify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the GestPayWS library.
5
 *
6
 * (c) Manuel Dalla Lana <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EndelWar\GestPayWS\Parameter;
13
14
use EndelWar\GestPayWS\ArrayAccessTrait;
15
16
/**
17
 * Class Parameter
18
 */
19
abstract class Parameter implements \ArrayAccess
20
{
21
    use ArrayAccessTrait;
22
23
    protected $mandatoryParameters = [];
24
25
    /**
26
     * @param array $parameters
27
     */
28
    public function __construct(array $parameters = [])
29
    {
30
        foreach ($this->parametersName as $parameterName) {
31
            $this->set($parameterName, null);
32
        }
33
        if (!empty($parameters)) {
34
            $this->fromArray($parameters);
35
        }
36
    }
37
38
    /**
39
     * @return bool
40
     */
41
    public function areAllMandatoryParametersSet()
42
    {
43
        foreach ($this->mandatoryParameters as $param) {
44
            if (!isset($this->$param)) {
45
                return false;
46
            }
47
        }
48
49
        return true;
50
    }
51
}
52