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

OrderByOrderNumberGetRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 49
ccs 7
cts 11
cp 0.6364
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A ofOrderNumber() 0 4 1
A getOrderNumber() 0 4 1
A setOrderNumber() 0 4 1
A getPath() 0 4 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