Completed
Push — master ( 122bdb...4f8f85 )
by Jens
10:49 queued 41s
created

CustomerSetLocaleAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 7 7 1
A ofLocale() 4 4 1
A __construct() 5 5 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\Request\Customers\Command;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Model\Common\LocaleTrait;
10
use Commercetools\Core\Request\AbstractAction;
11
12
/**
13
 * @package Commercetools\Core\Request\Customers\Command
14
 *
15
 * @method string getAction()
16
 * @method CustomerSetLocaleAction setAction(string $action = null)
17
 * @method string getLocale()
18
 */
19 View Code Duplication
class CustomerSetLocaleAction extends AbstractAction
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...
20
{
21
    use LocaleTrait;
22
23 11
    public function fieldDefinitions()
24
    {
25
        return [
26 11
            'action' => [static::TYPE => 'string'],
27 11
            'locale' => [static::TYPE => 'string'],
28
        ];
29
    }
30
31
    /**
32
     * @param string $locale
33
     * @param Context|callable $context
34
     * @return CustomerSetLocaleAction
35
     */
36 11
    public static function ofLocale($locale, $context = null)
37
    {
38 11
        return static::of($context)->setLocale($locale);
39
    }
40
41
    /**
42
     * @param array $data
43
     * @param Context|callable $context
44
     */
45 11
    public function __construct(array $data = [], $context = null)
46
    {
47 11
        parent::__construct($data, $context);
48 11
        $this->setAction('setLocale');
49 11
    }
50
}
51