Completed
Push — master ( fad61c...4fed00 )
by Florian
11s
created

Payone_SessionStatus_Response_Abstract::toArray()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 4
nc 4
nop 0
1
<?php
2
/**
3
 *
4
 * NOTICE OF LICENSE
5
 *
6
 * This source file is subject to the GNU General Public License (GPL 3)
7
 * that is bundled with this package in the file LICENSE.txt
8
 *
9
 * DISCLAIMER
10
 *
11
 * Do not edit or add to this file if you wish to upgrade Payone to newer
12
 * versions in the future. If you wish to customize Payone for your
13
 * needs please refer to http://www.payone.de for more information.
14
 *
15
 * @category        Payone
16
 * @package         Payone_SessionStatus
17
 * @subpackage      Response
18
 * @copyright       Copyright (c) 2012 <[email protected]> - www.noovias.com
19
 * @author          Matthias Walter <[email protected]>
20
 * @license         <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
21
 * @link            http://www.noovias.com
22
 */
23
24
/**
25
 *
26
 * @category        Payone
27
 * @package         Payone_SessionStatus
28
 * @subpackage      Response
29
 * @copyright       Copyright (c) 2012 <[email protected]> - www.noovias.com
30
 * @license         <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
31
 * @link            http://www.noovias.com
32
 */
33
34
35
36
abstract class Payone_SessionStatus_Response_Abstract
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
37
    implements Payone_SessionStatus_Response_Interface
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
38
{
39
    /**
40
     * @param $name
41
     * @return null|mixed
42
     */
43
    protected function get($name)
44
    {
45
        if (property_exists($this, $name)) {
46
            return $this->$name;
47
        }
48
49
        return null;
50
    }
51
52
    /**
53
     * @param string $name
54
     * @param mixed $value
55
     * @return boolean|null
56
     */
57
    protected function set($name, $value)
58
    {
59
        if (property_exists($this, $name)) {
60
            $this->$name = $value;
61
            return true;
62
        }
63
64
        return null;
65
    }
66
67
    /**
68
     * @return array
69
     */
70
    public function toArray()
71
    {
72
        $result = array();
73
        foreach ($this as $key => $data)
0 ignored issues
show
Bug introduced by
The expression $this of type this<Payone_SessionStatus_Response_Abstract> is not traversable.
Loading history...
74
        {
75
            if ($data === null) {
76
                continue;
77
            }
78
            elseif ($data instanceof Payone_Protocol_Service_ApplyFilters == false) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
79
                $result[$key] = $data;
80
            }
81
        }
82
83
        ksort($result);
84
85
        return $result;
86
    }
87
}
88