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

CustomerAddStoreAction::__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\Store;
8
use Commercetools\Core\Model\Store\StoreReference;
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#add-store-beta
15
 *
16
 * @method string getAction()
17
 * @method CustomerAddStoreAction setAction(string $action = null)
18
 * @method StoreReference getStore()
19
 * @method CustomerAddStoreAction setStore(StoreReference $store = null)
20
 */
21
class CustomerAddStoreAction extends AbstractAction
22
{
23
    use LocaleTrait;
24
25 3
    public function fieldDefinitions()
26
    {
27
        return [
28 3
            'action' => [static::TYPE => 'string'],
29 3
            'store' => [static::TYPE => StoreReference::class]
30
        ];
31
    }
32
33
    /**
34
     * @param array $data
35
     * @param Context|callable $context
36
     */
37 3
    public function __construct(array $data = [], $context = null)
38
    {
39 3
        parent::__construct($data, $context);
40 3
        $this->setAction('addStore');
41 3
    }
42
43
    /**
44
     * @param StoreReference $store
45
     * @param Context|callable $context
46
     * @return CustomerAddStoreAction
47
     */
48 1
    public static function ofStore(StoreReference $store, $context = null)
49
    {
50 1
        return static::of($context)->setStore($store);
51
    }
52
}
53