Completed
Push — develop ( 79f8cb...57f680 )
by Jens
09:18
created

PaymentReference   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 1
dl 22
loc 22
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 7 7 1
A ofId() 4 4 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
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Payment;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Model\Common\Reference;
10
11
/**
12
 * @package Commercetools\Core\Model\Payment
13
 * @link https://dev.commercetools.com/http-api-types.html#reference-types
14
 * @link https://dev.commercetools.com/http-api-projects-payments.html#payment
15
 * @method string getTypeId()
16
 * @method PaymentReference setTypeId(string $typeId = null)
17
 * @method string getId()
18
 * @method PaymentReference setId(string $id = null)
19
 * @method Payment getObj()
20
 * @method PaymentReference setObj(Payment $obj = null)
21
 * @method string getKey()
22
 * @method PaymentReference setKey(string $key = null)
23
 */
24 View Code Duplication
class PaymentReference extends Reference
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...
25
{
26
    const TYPE_PAYMENT = 'payment';
27
28 1
    public function fieldDefinitions()
29
    {
30 1
        $fields = parent::fieldDefinitions();
31 1
        $fields[static::OBJ] = [static::TYPE => '\Commercetools\Core\Model\Payment\Payment'];
32
33 1
        return $fields;
34
    }
35
36
    /**
37
     * @param $id
38
     * @param Context|callable $context
39
     * @return PaymentReference
40
     */
41 1
    public static function ofId($id, $context = null)
42
    {
43 1
        return static::ofTypeAndId(static::TYPE_PAYMENT, $id, $context);
44
    }
45
}
46