Completed
Push — develop ( b9461b...c75e53 )
by Jens
12:01
created

ProductDiscount   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 33
loc 33
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B fieldDefinitions() 30 30 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 @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\ProductDiscount;
7
8
use Commercetools\Core\Model\Common\Resource;
9
use Commercetools\Core\Model\Common\LocalizedString;
10
use Commercetools\Core\Model\Common\ReferenceCollection;
11
use Commercetools\Core\Model\Common\DateTimeDecorator;
12
use DateTime;
13
14
/**
15
 * @package Commercetools\Core\Model\ProductDiscount
16
 * @link https://docs.commercetools.com/http-api-projects-productDiscounts.html#productdiscount
17
 * @method string getId()
18
 * @method ProductDiscount setId(string $id = null)
19
 * @method int getVersion()
20
 * @method ProductDiscount setVersion(int $version = null)
21
 * @method DateTimeDecorator getCreatedAt()
22
 * @method ProductDiscount setCreatedAt(DateTime $createdAt = null)
23
 * @method DateTimeDecorator getLastModifiedAt()
24
 * @method ProductDiscount setLastModifiedAt(DateTime $lastModifiedAt = null)
25
 * @method LocalizedString getName()
26
 * @method ProductDiscount setName(LocalizedString $name = null)
27
 * @method LocalizedString getDescription()
28
 * @method ProductDiscount setDescription(LocalizedString $description = null)
29
 * @method ProductDiscountValue getValue()
30
 * @method ProductDiscount setValue(ProductDiscountValue $value = null)
31
 * @method mixed getPredicate()
32
 * @method ProductDiscount setPredicate($predicate = null)
33
 * @method string getSortOrder()
34
 * @method ProductDiscount setSortOrder(string $sortOrder = null)
35
 * @method bool getIsActive()
36
 * @method ProductDiscount setIsActive(bool $isActive = null)
37
 * @method ReferenceCollection getReferences()
38
 * @method ProductDiscount setReferences(ReferenceCollection $references = null)
39
 * @method DateTimeDecorator getValidFrom()
40
 * @method ProductDiscount setValidFrom(DateTime $validFrom = null)
41
 * @method DateTimeDecorator getValidUntil()
42
 * @method ProductDiscount setValidUntil(DateTime $validUntil = null)
43
 * @method ProductDiscountReference getReference()
44
 */
45 View Code Duplication
class ProductDiscount extends Resource
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...
46
{
47 14
    public function fieldDefinitions()
48
    {
49
        return [
50 14
            'id' => [static::TYPE => 'string'],
51 14
            'version' => [static::TYPE => 'int'],
52
            'createdAt' => [
53 14
                static::TYPE => DateTime::class,
54 14
                static::DECORATOR => DateTimeDecorator::class
55
            ],
56
            'lastModifiedAt' => [
57 14
                static::TYPE => DateTime::class,
58 14
                static::DECORATOR => DateTimeDecorator::class
59
            ],
60 14
            'name' => [static::TYPE => LocalizedString::class],
61 14
            'description' => [static::TYPE => LocalizedString::class],
62 14
            'value' => [static::TYPE => ProductDiscountValue::class],
63
            'predicate' => [],
64 14
            'sortOrder' => [static::TYPE => 'string'],
65 14
            'isActive' => [static::TYPE => 'bool'],
66 14
            'references' => [static::TYPE => ReferenceCollection::class],
67
            'validFrom' => [
68 14
                static::TYPE => DateTime::class,
69 14
                static::DECORATOR => DateTimeDecorator::class
70
            ],
71
            'validUntil' => [
72 14
                static::TYPE => DateTime::class,
73 14
                static::DECORATOR => DateTimeDecorator::class
74
            ],
75
        ];
76
    }
77
}
78