Payone_Api_Mapper_Response_GetInvoice::map()   B
last analyzed

Complexity

Conditions 9
Paths 3

Size

Total Lines 20
Code Lines 12

Duplication

Lines 20
Ratio 100 %

Importance

Changes 0
Metric Value
dl 20
loc 20
rs 7.756
c 0
b 0
f 0
cc 9
eloc 12
nc 3
nop 1
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_GetInvoice
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
34
    extends Payone_Api_Mapper_Response_Abstract
35
    implements Payone_Api_Mapper_Response_Interface
36
{
37
38
    /**
39
     * @param array $params
40
     *
41
     * @return Payone_Api_Response_Capture_Approved|Payone_Api_Response_Error
42
     * @throws Payone_Api_Exception_UnknownStatus
43
     */
44
    public function map(array $params)
45
    {
46
        $this->setParams($params);
47
48
        if ($this->isError()) {
49
            $response = new Payone_Api_Response_Error($params);
50
        }
51
        elseif (empty($params) || $this->isApproved() || $this->isBlocked() || $this->isEnrolled() ||
52
            $this->isInvalid() || $this->isRedirect() || $this->isValid()
53
        ) {
54
            throw new Payone_Api_Exception_UnknownStatus();
55
        }
56
        else {
57
            $params = array('response' => $params);
58
            $response = new Payone_Api_Response_Management_GetInvoice($params);
59
            $response->setStatus(Payone_Api_Enum_ResponseType::VALID);
60
        }
61
62
        return $response;
63
    }
64
}
65