Completed
Push — master ( 7d6b3f...2df636 )
by Fabian
14s queued 10s
created

OrderFixture::getShippingMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

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
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace TddWizard\Fixtures\Sales;
5
6
use Magento\Sales\Model\Order;
7
8
class OrderFixture
9
{
10
    /**
11
     * @var Order
12
     */
13
    private $order;
14
15 19
    public function __construct(Order $order)
16
    {
17 19
        $this->order = $order;
18 19
    }
19
20 18
    public function getId(): int
21
    {
22 18
        return (int) $this->order->getEntityId();
23
    }
24
25 16
    public function getCustomerId(): int
26
    {
27 16
        return (int) $this->order->getCustomerId();
28
    }
29
30 2
    public function getCustomerEmail(): string
31
    {
32 2
        return (string) $this->order->getCustomerEmail();
33
    }
34
35
    /**
36
     * Obtain `qty_ordered` per order item, indexed with `item_id`.
37
     *
38
     * @return float[]
39
     */
40 5
    public function getOrderItemQtys(): array
41
    {
42 5
        $qtys = [];
43 5
        foreach ($this->order->getItems() as $item) {
44 5
            $qtys[$item->getItemId()] = $item->getQtyOrdered();
45
        }
46
47 5
        return $qtys;
48
    }
49
50 1
    public function getPaymentMethod(): string
51
    {
52 1
        return $this->order->getPayment()->getMethod();
53
    }
54
55 1
    public function getShippingMethod(): string
56
    {
57 1
        return $this->order->getShippingMethod();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->order->getShippingMethod() could return the type Magento\Framework\DataObject|null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
58
    }
59
60
    public function rollback(): void
61
    {
62
        OrderFixtureRollback::create()->execute($this);
63
    }
64
}
65