Completed
Push — develop ( f9d81f...e6fafc )
by Jens
09:13
created

ChannelReference   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

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