Completed
Push — master ( df7b08...6ca0e7 )
by Harald
05:46 queued 02:54
created

Shipping   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 26
loc 26
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getInfo() 12 12 2
A getClass() 10 10 2

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
  * osCommerce Online Merchant
4
  *
5
  * @copyright (c) 2016 osCommerce; https://www.oscommerce.com
6
  * @license MIT; https://www.oscommerce.com/license/mit.txt
7
  */
8
9
namespace OSC\OM\Modules;
10
11
use OSC\OM\Apps;
12
13 View Code Duplication
class Shipping extends \OSC\OM\ModulesAbstract
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...
14
{
15
    public function getInfo($app, $key, $data)
16
    {
17
        $result = [];
18
19
        $class = $this->ns . $app . '\\' . $data;
20
21
        if (is_subclass_of($class, 'OSC\OM\Modules\\' . $this->code . 'Interface')) {
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if 'OSC\\OM\\Modules\\' . $this->code . 'Interface' can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
22
            $result[$app . '\\' . $key] = $class;
23
        }
24
25
        return $result;
26
    }
27
28
    public function getClass($module)
29
    {
30
        list($vendor, $app, $code) = explode('\\', $module, 3);
31
32
        $info = Apps::getInfo($vendor . '\\' . $app);
33
34
        if (isset($info['modules'][$this->code][$code])) {
35
            return $this->ns . $vendor . '\\' . $app . '\\' . $info['modules'][$this->code][$code];
36
        }
37
    }
38
}
39