Passed
Pull Request — master (#52)
by Fabian
19:55
created

OrderFixture::rollback()   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 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
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 19
    public function __construct(OrderInterface $order)
15
    {
16 19
        $this->order = $order;
17 19
    }
18
19 18
    public function getId(): int
20
    {
21 18
        return (int) $this->order->getEntityId();
22
    }
23
24 16
    public function getCustomerId(): int
25
    {
26 16
        return (int) $this->order->getCustomerId();
27
    }
28
29 2
    public function getCustomerEmail(): string
30
    {
31 2
        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 5
    public function getOrderItemQtys(): array
40
    {
41 5
        $qtys = [];
42 5
        foreach ($this->order->getItems() as $item) {
43 5
            $qtys[$item->getItemId()] = $item->getQtyOrdered();
44
        }
45
46 5
        return $qtys;
47
    }
48
49 1
    public function getPaymentMethod(): string
50
    {
51 1
        return $this->order->getPayment()->getMethod();
52
    }
53
54 1
    public function getShippingMethod(): string
55
    {
56 1
        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
    public function rollback(): void
60
    {
61
        OrderFixtureRollback::create()->execute($this);
62
    }
63
}
64