This repository has been archived by the owner on Aug 22, 2023. It is now read-only.
forked from quafzi/payone-magento
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Abstract.php
130 lines (115 loc) · 3.13 KB
/
Abstract.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
*
* NOTICE OF LICENSE
*
* This source file is subject to the GNU General Public License (GPL 3)
* that is bundled with this package in the file LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Payone to newer
* versions in the future. If you wish to customize Payone for your
* needs please refer to http://www.payone.de for more information.
*
* @category Payone
* @package Payone_SessionStatus
* @subpackage Request
* @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
* @author Matthias Walter <info@noovias.com>
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
* @link http://www.noovias.com
*/
/**
*
* @category Payone
* @package Payone_SessionStatus
* @subpackage Request
* @copyright Copyright (c) 2012 <info@noovias.com> - www.noovias.com
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
* @link http://www.noovias.com
*/
abstract class Payone_SessionStatus_Request_Abstract
implements Payone_SessionStatus_Request_Interface
{
/**
* @var Payone_Protocol_Service_ApplyFilters
*/
private $applyFilters = NULL;
function __construct(array $params = array())
{
if (count($params) > 0) {
$this->init($params);
}
}
public function init(array $data = array())
{
foreach ($data as $key => $value)
{
$this->set($key, $value);
}
}
/**
* @return string
*/
public function __toString()
{
if($this->applyFilters) {
$result = $this->applyFilters->apply($this->toArray());
} else {
$protocolFactory = new Payone_Protocol_Factory();
$defaultApplyFilters = $protocolFactory->buildServiceApplyFilters();
$result = $defaultApplyFilters->apply($this->toArray());
}
return $result;
}
/**
* @return array
*/
public function toArray()
{
$result = array();
foreach ($this as $key => $data)
{
if ($data === null) {
continue;
}
elseif ($data instanceof Payone_Protocol_Service_ApplyFilters == false) {
$result[$key] = $data;
}
}
ksort($result);
return $result;
}
/**
* @param $name
* @return null|mixed
*/
public function get($name)
{
if (property_exists($this, $name)) {
return $this->$name;
}
return null;
}
/**
* @param string $name
* @param mixed $value
* @return boolean|null
*/
public function set($name, $value)
{
if (property_exists($this, $name)) {
$this->$name = $value;
return true;
}
return null;
}
/**
* @param Payone_Protocol_Service_ApplyFilters $applyFilters
*/
public function setApplyFilters(Payone_Protocol_Service_ApplyFilters $applyFilters)
{
$this->applyFilters = $applyFilters;
}
}