Passed
Push — master ( 3f8301...c7321f )
by Jens
42:49 queued 17:59
created

CustomerSetStoresAction::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Commercetools\Core\Request\Customers\Command;
4
5
use Commercetools\Core\Model\Common\Context;
6
use Commercetools\Core\Model\Common\LocaleTrait;
7
use Commercetools\Core\Model\Store\StoreReference;
8
use Commercetools\Core\Model\Store\StoreReferenceCollection;
9
use Commercetools\Core\Request\AbstractAction;
10
11
/**
12
 * @package Commercetools\Core\Request\Customers\Command
13
 *
14
 * @link https://docs.commercetools.com/http-api-projects-customers.html#set-stores-beta
15
 *
16
 * @method string getAction()
17
 * @method CustomerSetStoresAction setAction(string $action = null)
18
 * @method StoreReferenceCollection getStores()
19
 * @method CustomerSetStoresAction setStores(StoreReferenceCollection $stores = null)
20
 */
21
class CustomerSetStoresAction extends AbstractAction
22
{
23
    use LocaleTrait;
24
25 3
    public function fieldDefinitions()
26
    {
27
        return [
28 3
            'action' => [static::TYPE => 'string'],
29 3
            'stores' => [static::TYPE => StoreReferenceCollection::class],
30
        ];
31
    }
32
33
    /**
34
     * @param StoreReferenceCollection $stores
35
     * @param Context|callable $context
36
     * @return CustomerSetStoresAction
37
     */
38 1
    public static function ofStores(StoreReferenceCollection $stores, $context = null)
39
    {
40 1
        return static::of($context)->setStores($stores);
41
    }
42
43
    /**
44
     * @param array $data
45
     * @param Context|callable $context
46
     */
47 3
    public function __construct(array $data = [], $context = null)
48
    {
49 3
        parent::__construct($data, $context);
50 3
        $this->setAction('setStores');
51 3
    }
52
}
53