Completed
Push — develop ( 973129...524b9a )
by Jens
08:43
created

Review::fieldDefinitions()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 27
ccs 19
cts 19
cp 1
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 22
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Review;
7
8
use Commercetools\Core\Model\Common\Resource;
9
use Commercetools\Core\Model\Common\DateTimeDecorator;
10
use Commercetools\Core\Model\State\StateReference;
11
use Commercetools\Core\Model\Common\ResourceIdentifier;
12
use Commercetools\Core\Model\Customer\CustomerReference;
13
use Commercetools\Core\Model\CustomField\CustomFieldObject;
14
15
/**
16
 * @package Commercetools\Core\Model\Review
17
 * @link https://dev.commercetools.com/http-api-projects-reviews.html#review
18
 * @method string getId()
19
 * @method Review setId(string $id = null)
20
 * @method int getVersion()
21
 * @method Review setVersion(int $version = null)
22
 * @method DateTimeDecorator getCreatedAt()
23
 * @method Review setCreatedAt(\DateTime $createdAt = null)
24
 * @method DateTimeDecorator getLastModifiedAt()
25
 * @method Review setLastModifiedAt(\DateTime $lastModifiedAt = null)
26
 * @method string getProductId()
27
 * @method Review setProductId(string $productId = null)
28
 * @method string getCustomerId()
29
 * @method Review setCustomerId(string $customerId = null)
30
 * @method string getAuthorName()
31
 * @method Review setAuthorName(string $authorName = null)
32
 * @method string getTitle()
33
 * @method Review setTitle(string $title = null)
34
 * @method string getText()
35
 * @method Review setText(string $text = null)
36
 * @method float getScore()
37
 * @method Review setScore(float $score = null)
38
 * @method StateReference getState()
39
 * @method Review setState(StateReference $state = null)
40
 * @method string getKey()
41
 * @method Review setKey(string $key = null)
42
 * @method string getUniquenessValue()
43
 * @method Review setUniquenessValue(string $uniquenessValue = null)
44
 * @method string getLocale()
45
 * @method Review setLocale(string $locale = null)
46
 * @method ResourceIdentifier getTarget()
47
 * @method Review setTarget(ResourceIdentifier $target = null)
48
 * @method int getRating()
49
 * @method Review setRating(int $rating = null)
50
 * @method bool getIncludedInStatistics()
51
 * @method Review setIncludedInStatistics(bool $includedInStatistics = null)
52
 * @method CustomerReference getCustomer()
53
 * @method Review setCustomer(CustomerReference $customer = null)
54
 * @method CustomFieldObject getCustom()
55
 * @method Review setCustom(CustomFieldObject $custom = null)
56
 */
57
class Review extends Resource
58
{
59 4
    public function fieldDefinitions()
60
    {
61
        return [
62 4
            'id' => [static::TYPE => 'string'],
63 4
            'version' => [static::TYPE => 'int'],
64
            'createdAt' => [
65 4
                static::TYPE => '\DateTime',
66 4
                static::DECORATOR => '\Commercetools\Core\Model\Common\DateTimeDecorator'
67
            ],
68
            'lastModifiedAt' => [
69 4
                static::TYPE => '\DateTime',
70 4
                static::DECORATOR => '\Commercetools\Core\Model\Common\DateTimeDecorator'
71
            ],
72 4
            'key' => [static::TYPE => 'string'],
73 4
            'uniquenessValue' => [static::TYPE => 'string'],
74 4
            'locale' => [static::TYPE => 'string'],
75 4
            'authorName' => [static::TYPE => 'string'],
76 4
            'title' => [static::TYPE => 'string'],
77 4
            'text' => [static::TYPE => 'string'],
78 4
            'target' => [static::TYPE => '\Commercetools\Core\Model\Common\ResourceIdentifier'],
79 4
            'rating' => [static::TYPE => 'int'],
80 4
            'state' => [static::TYPE => '\Commercetools\Core\Model\State\StateReference'],
81 4
            'includedInStatistics' => [static::TYPE => 'bool'],
82 4
            'customer' => [static::TYPE => '\Commercetools\Core\Model\Customer\CustomerReference'],
83 4
            'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObject'],
84
        ];
85
    }
86
87 View Code Duplication
    public function jsonSerialize()
0 ignored issues
show
Duplication introduced by
This method 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...
88
    {
89
        $data = parent::jsonSerialize();
90
        if (isset($data['locale'])) {
91
            $data['locale'] = str_replace('_', '-', $data['locale']);
92
        }
93
        return $data;
94
    }
95
}
96