Completed
Push — master ( a6e4ea...ae9fdb )
by Florian
14s
created

Payone_Api_Mapper_Response_Preauthorization   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 6
dl 34
loc 34
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B map() 22 22 5

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
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...
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...
34
    extends Payone_Api_Mapper_Response_Abstract
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
Coding Style introduced by
Expected 0 spaces between "Payone_Api_Mapper_Response_Abstract" and comma; 1 found
Loading history...
35
    implements Payone_Api_Mapper_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...
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