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_Api |
17
|
|
|
* @subpackage Mapper |
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_Api |
28
|
|
|
* @subpackage Mapper |
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
|
|
View Code Duplication |
class Payone_Api_Mapper_Response_Preauthorization |
|
|
|
|
34
|
|
|
extends Payone_Api_Mapper_Response_Abstract |
|
|
|
|
35
|
|
|
implements Payone_Api_Mapper_Response_Interface |
|
|
|
|
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* @param array $params |
39
|
|
|
* |
40
|
|
|
* @return Payone_Api_Response_Error|Payone_Api_Response_Preauthorization_Approved|Payone_Api_Response_Preauthorization_Redirect |
41
|
|
|
* @throws Payone_Api_Exception_UnknownStatus |
42
|
|
|
*/ |
43
|
|
|
public function map(array $params) |
44
|
|
|
{ |
45
|
|
|
$this->setParams($params); |
46
|
|
|
|
47
|
|
|
if ($this->isApproved()) { |
48
|
|
|
$response = new Payone_Api_Response_Preauthorization_Approved($params); |
49
|
|
|
} |
50
|
|
|
elseif ($this->isRedirect()) { |
51
|
|
|
$response = new Payone_Api_Response_Preauthorization_Redirect($params); |
52
|
|
|
} |
53
|
|
|
elseif ($this->isPending()) { |
54
|
|
|
$response = new Payone_Api_Response_Preauthorization_Pending($params); |
55
|
|
|
} |
56
|
|
|
elseif ($this->isError()) { |
57
|
|
|
$response = new Payone_Api_Response_Error($params); |
58
|
|
|
} |
59
|
|
|
else { |
60
|
|
|
throw new Payone_Api_Exception_UnknownStatus(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
return $response; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.