Passed
Push — develop ( a56d3b...9e66f0 )
by Jens
65:43 queued 48:05
created

ofAddressIdAndAddress()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 3
crap 1
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Request\Customers\Command;
7
8
use Commercetools\Core\Model\Common\Address;
9
use Commercetools\Core\Model\Common\Context;
10
use Commercetools\Core\Request\AbstractAction;
11
12
/**
13
 * @package Commercetools\Core\Request\Customers\Command
14
 * @link https://docs.commercetools.com/http-api-projects-customers.html#change-address
15
 * @method string getAddressId()
16
 * @method Address getAddress()
17
 * @method CustomerChangeAddressAction setAddressId(string $addressId = null)
18
 * @method CustomerChangeAddressAction setAddress(Address $address = null)
19
 * @method string getAction()
20
 * @method CustomerChangeAddressAction setAction(string $action = null)
21
 * @method string getAddressKey()
22
 * @method CustomerChangeAddressAction setAddressKey(string $addressKey = null)
23
 */
24
class CustomerChangeAddressAction extends AbstractAction
25
{
26 6
    public function fieldDefinitions()
27
    {
28
        return [
29 6
            'action' => [static::TYPE => 'string'],
30 6
            'addressId' => [static::TYPE => 'string'],
31 6
            'addressKey' => [static::TYPE => 'string'],
32 6
            'address' => [static::TYPE => Address::class],
33
        ];
34
    }
35
36
    /**
37
     * @param array $data
38
     * @param Context|callable $context
39
     */
40 6
    public function __construct(array $data = [], $context = null)
41
    {
42 6
        parent::__construct($data, $context);
43 6
        $this->setAction('changeAddress');
44 6
    }
45
46
    /**
47
     * @param string $addressId
48
     * @param Address $address
49
     * @param Context|callable $context
50
     * @return CustomerChangeAddressAction
51
     */
52 2
    public static function ofAddressIdAndAddress($addressId, Address $address, $context = null)
53
    {
54 2
        return static::of($context)->setAddressId($addressId)->setAddress($address);
55
    }
56
57
    /**
58
     * @param string $addressKey
59
     * @param Address $address
60
     * @param Context|callable $context
61
     * @return CustomerChangeAddressAction
62
     */
63 2
    public static function ofAddressKeyAndAddress($addressKey, Address $address, $context = null)
64
    {
65 2
        return static::of($context)->setAddressKey($addressKey)->setAddress($address);
66
    }
67
}
68