Completed
Push — develop ( 23d173...53a8f0 )
by
unknown
17:15
created

DiscountCodeChangeGroupsAction::fieldDefinitions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Request\DiscountCodes\Command;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Request\AbstractAction;
10
11
/**
12
 * @package Commercetools\Core\Request\DiscountCodes\Command
13
 * @link https://dev.commercetools.com/http-api-projects-discountCodes.html#change-groups
14
 * @method string getAction()
15
 * @method DiscountCodeChangeGroupsAction setAction(string $action = null)
16
 * @method array getGroups()
17
 * @method DiscountCodeChangeGroupsAction setGroups(array $groups = null)
18
 */
19 View Code Duplication
class DiscountCodeChangeGroupsAction 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 1
    public function fieldDefinitions()
22
    {
23
        return [
24 1
            'action' => [static::TYPE => 'string'],
25 1
            'groups' => [static::TYPE => 'array'],
26
        ];
27
    }
28
29
    /**
30
     * @param array $data
31
     * @param Context|callable $context
32
     */
33 1
    public function __construct(array $data = [], $context = null)
34
    {
35 1
        parent::__construct($data, $context);
36 1
        $this->setAction('changeGroups');
37 1
    }
38
39
    /**
40
     * @param bool $groups
41
     * @param Context|callable $context
42
     * @return DiscountCodeChangeGroupsAction
43
     */
44
    public static function ofGroups($groups, $context = null)
45
    {
46
        return static::of($context)->setGroups($groups);
0 ignored issues
show
Documentation introduced by
$groups is of type boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
47
    }
48
}
49