Completed
Push — master ( 184d52...247cd7 )
by Andrii
02:13
created

OmnipayRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 25 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 44.44%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 1
cbo 3
dl 8
loc 32
ccs 4
cts 9
cp 0.4444
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getWorker() 8 8 2
A getData() 0 7 1

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
 * Generalization over Omnipay and Payum
4
 *
5
 * @link      https://github.com/hiqdev/php-merchant
6
 * @package   php-merchant
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\merchant;
12
13
class OmnipayRequest extends AbstractRequest
14
{
15
    /**
16
     * @var \Omnipay\Common\Message\AbstractRequest Omnipay Request object
17
     */
18
    protected $_worker;
19
20
    /**
21
     * @var OmnipayMerchant
22
     */
23
    public $merchant;
24
25
    /**
26
     * @return \Omnipay\Common\Message\AbstractRequest
27
     */
28 View Code Duplication
    public function getWorker()
0 ignored issues
show
Duplication introduced by
This method 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...
29
    {
30
        if ($this->_worker === null) {
31
            $this->_worker = $this->merchant->getWorker()->{$this->getType()}($this->getData());
32
        }
33
34
        return $this->_worker;
35
    }
36
37 1
    public function getData()
38
    {
39 1
        $this->data['sum'] = Helper::formatMoney($this->data['sum']);
40 1
        $this->data['amount'] = Helper::formatMoney($this->data['amount']);
41
42 1
        return $this->data;
43
    }
44
}
45