Passed
Branch develop (dc1a10)
by Jens
08:20
created

OrderByOrderNumberGetRequest::ofOrderNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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