Completed
Push — master ( 51c17f...9ad827 )
by Fabian
14s queued 10s
created

OrderFixture::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace TddWizard\Fixtures\Sales;
4
5
use Magento\Sales\Api\Data\OrderInterface;
6
7
class OrderFixture
8
{
9
    /**
10
     * @var OrderInterface
11
     */
12
    private $order;
13
14
    public function __construct(OrderInterface $order)
15
    {
16
        $this->order = $order;
17
    }
18
19
    public function getId(): int
20
    {
21
        return (int) $this->order->getEntityId();
22
    }
23
24
    public function getCustomerId(): int
25
    {
26
        return (int) $this->order->getCustomerId();
27
    }
28
29
    public function getCustomerEmail(): string
30
    {
31
        return (string) $this->order->getCustomerEmail();
32
    }
33
34
    /**
35
     * Obtain `qty_ordered` per order item, indexed with `item_id`.
36
     *
37
     * @return int[]
38
     */
39
    public function getOrderItemQtys(): array
40
    {
41
        $qtys = [];
42
        foreach ($this->order->getItems() as $item) {
43
            $qtys[$item->getItemId()] = $item->getQtyOrdered();
44
        }
45
46
        return $qtys;
47
    }
48
49
    public function getPaymentMethod(): string
50
    {
51
        return $this->order->getPayment()->getMethod();
52
    }
53
54
    public function getShippingMethod(): string
55
    {
56
        return $this->order->getShippingMethod();
0 ignored issues
show
Bug introduced by
The method getShippingMethod() does not exist on Magento\Sales\Api\Data\OrderInterface. Did you maybe mean getShippingAmount()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
        return $this->order->/** @scrutinizer ignore-call */ getShippingMethod();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
    }
58
}
59