Completed
Push — develop ( 046464...9a0cd6 )
by Jens
13:20
created

ChannelDraft   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 10 10 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
 */
5
6
namespace Commercetools\Core\Model\Channel;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Model\Common\JsonObject;
10
use Commercetools\Core\Model\Common\LocalizedString;
11
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft;
12
13
/**
14
 * @package Commercetools\Core\Model\Channel
15
 * @link https://dev.commercetools.com/http-api-projects-channels.html#create-channel
16
 * @method string getKey()
17
 * @method ChannelDraft setKey(string $key = null)
18
 * @method array getRoles()
19
 * @method ChannelDraft setRoles(array $roles = null)
20
 * @method LocalizedString getName()
21
 * @method ChannelDraft setName(LocalizedString $name = null)
22
 * @method LocalizedString getDescription()
23
 * @method ChannelDraft setDescription(LocalizedString $description = null)
24
 * @method CustomFieldObjectDraft getCustom()
25
 * @method ChannelDraft setCustom(CustomFieldObjectDraft $custom = null)
26
 */
27 View Code Duplication
class ChannelDraft extends JsonObject
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...
28
{
29 3
    public function fieldDefinitions()
30
    {
31
        return [
32 3
            'key' => [static::TYPE => 'string'],
33 3
            'roles' => [static::TYPE => 'array'],
34 3
            'name' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'],
35 3
            'description' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'],
36 3
            'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObjectDraft'],
37 3
        ];
38
    }
39
40
    /**
41
     * @param string $key
42
     * @param Context|callable $context
43
     * @return ChannelDraft
44
     */
45 3
    public static function ofKey($key, $context = null)
46
    {
47 3
        return static::of($context)->setKey($key);
48
    }
49
}
50