Passed
Push — develop ( 818a9c...df7c09 )
by Jens
14:52
created

OrderUpdateByOrderNumberRequest::getPath()   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 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Request\Orders;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Request\AbstractUpdateRequest;
10
use Commercetools\Core\Model\Order\Order;
11
use Commercetools\Core\Request\InStores\InStoreRequestDecorator;
12
use Commercetools\Core\Request\InStores\InStoreTrait;
13
use Commercetools\Core\Response\ApiResponseInterface;
14
use Commercetools\Core\Model\MapperInterface;
15
16
/**
17
 * @package Commercetools\Core\Request\Orders
18
 * @link https://docs.commercetools.com/http-api-projects-orders.html#update-order-by-ordernumber
19
 * @method Order mapResponse(ApiResponseInterface $response)
20
 * @method Order mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null)
21
 * @method OrderUpdateByOrderNumberRequest|InStoreRequestDecorator inStore($storeKey)
22
 */
23
class OrderUpdateByOrderNumberRequest extends AbstractUpdateRequest
24
{
25
    use InStoreTrait;
26
27
    protected $resultClass = Order::class;
28
29
    /**
30
     * @param string $orderNumber
31
     * @param int $version
32
     * @param array $actions
33
     * @param Context $context
34
     */
35 2
    public function __construct($orderNumber, $version, array $actions = [], Context $context = null)
36
    {
37 2
        parent::__construct(OrdersEndpoint::endpoint(), $orderNumber, $version, $actions, $context);
38 2
    }
39
40
    /**
41
     * @param string $orderNumber
42
     * @param int $version
43
     * @param Context $context
44
     * @return static
45
     */
46 2
    public static function ofOrderNumberAndVersion($orderNumber, $version, Context $context = null)
47
    {
48 2
        return new static($orderNumber, $version, [], $context);
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getOrderNumber()
55
    {
56
        return $this->getId();
57
    }
58
59
    /**
60
     * @param string $orderNumber
61
     * @return $this
62
     */
63
    public function setOrderNumber($orderNumber)
64
    {
65
        return $this->setId($orderNumber);
66
    }
67
68
    /**
69
     * @return string
70
     * @internal
71
     */
72 2
    protected function getPath()
73
    {
74 2
        return (string)$this->getEndpoint() . '/order-number=' . urlencode($this->getId()) . $this->getParamString();
75
    }
76
}
77