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

OrderByOrderNumberGetRequest::getOrderNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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\AbstractByIdGetRequest;
10
use Commercetools\Core\Request\InStores\InStoreRequestDecorator;
11
use Commercetools\Core\Request\InStores\InStoreTrait;
12
use Commercetools\Core\Response\ApiResponseInterface;
13
use Commercetools\Core\Model\Order\Order;
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#get-order-by-ordernumber
19
 * @method Order mapResponse(ApiResponseInterface $response)
20
 * @method Order mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null)
21
 * @method OrderByOrderNumberGetRequest|InStoreRequestDecorator inStore($storeKey)
22
 */
23
class OrderByOrderNumberGetRequest extends AbstractByIdGetRequest
24
{
25
    use InStoreTrait;
26
27
    protected $resultClass = Order::class;
28
29
    /**
30
     * @param string $orderNumber
31
     * @param Context $context
32
     */
33 2
    public function __construct($orderNumber, Context $context = null)
34
    {
35 2
        parent::__construct(OrdersEndpoint::endpoint(), $orderNumber, $context);
36 2
    }
37
38
    /**
39
     * @param string $orderNumber
40
     * @param Context $context
41
     * @return static
42
     */
43 2
    public static function ofOrderNumber($orderNumber, Context $context = null)
44
    {
45 2
        return new static($orderNumber, $context);
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getOrderNumber()
52
    {
53
        return $this->getId();
54
    }
55
56
    /**
57
     * @param string $orderNumber
58
     * @return $this
59
     */
60
    public function setOrderNumber($orderNumber)
61
    {
62
        return $this->setId($orderNumber);
63
    }
64
65
    /**
66
     * @return string
67
     * @internal
68
     */
69 2
    protected function getPath()
70
    {
71 2
        return (string)$this->getEndpoint() . '/order-number=' . urlencode($this->getId()) . $this->getParamString();
72
    }
73
}
74