Completed
Push — master ( ab9bf2...7d6b3f )
by Fabian
09:56 queued 01:25
created

OrderFixture::getPaymentMethod()   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
cc 1
eloc 1
c 1
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
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 3
    public function __construct(Order $order)
16
    {
17 3
        $this->order = $order;
18 3
    }
19
20 2
    public function getId(): int
21
    {
22 2
        return (int) $this->order->getEntityId();
23
    }
24
25
    public function getCustomerId(): int
26
    {
27
        return (int) $this->order->getCustomerId();
28
    }
29
30
    public function getCustomerEmail(): string
31
    {
32
        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
    public function getOrderItemQtys(): array
41
    {
42
        $qtys = [];
43
        foreach ($this->order->getItems() as $item) {
44
            $qtys[$item->getItemId()] = $item->getQtyOrdered();
45
        }
46
47
        return $qtys;
48
    }
49
50
    public function getPaymentMethod(): string
51
    {
52
        return $this->order->getPayment()->getMethod();
53
    }
54
55
    public function getShippingMethod(): string
56
    {
57
        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