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

ReviewSetLocaleAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 27.59 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 8
loc 29
ccs 0
cts 12
cp 0
rs 10
c 2
b 1
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 0 7 1
A __construct() 0 5 1
A jsonSerialize() 8 8 2

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\Request\Reviews\Command;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Request\AbstractAction;
10
11
/**
12
 * @package Commercetools\Core\Request\Reviews\Command
13
 * @link https://dev.commercetools.com/http-api-projects-reviews.html#set-locale
14
 * @method string getAction()
15
 * @method ReviewSetLocaleAction setAction(string $action = null)
16
 * @method string getLocale()
17
 * @method ReviewSetLocaleAction setLocale(string $locale = null)
18
 */
19
class ReviewSetLocaleAction extends AbstractAction
20
{
21
    public function fieldDefinitions()
22
    {
23
        return [
24
            'action' => [static::TYPE => 'string'],
25
            'locale' => [static::TYPE => 'string'],
26
        ];
27
    }
28
29
    /**
30
     * @param array $data
31
     * @param Context|callable $context
32
     */
33
    public function __construct(array $data = [], $context = null)
34
    {
35
        parent::__construct($data, $context);
36
        $this->setAction('setLocale');
37
    }
38
39 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...
40
    {
41
        $data = parent::jsonSerialize();
42
        if (isset($data['locale'])) {
43
            $data['locale'] = str_replace('_', '-', $data['locale']);
44
        }
45
        return $data;
46
    }
47
}
48