OrderItems   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A payloadConfig() 0 7 2
1
<?php declare(strict_types=1);
2
3
namespace Getloy\TransactionDetails;
4
5
/**
6
 * Transaction order items.
7
 */
8
class OrderItems
9
{
10
    protected $orderItems = [];
11
12
    /**
13
     * Add order item.
14
     *
15
     * @param OrderItem $orderItem Order item
16
     * @return void
17
     */
18
    public function add(OrderItem $orderItem)
19
    {
20
        $this->orderItems[] = $orderItem;
21
    }
22
23
    /**
24
     * Generate partial GetLoy widget payload configuration for the instance.
25
     *
26
     * @return array Partial widget payload configuration.
27
     */
28
    public function payloadConfig(): array
29
    {
30
        $payload = [];
31
        foreach ($this->orderItems as $item) {
32
            $payload[] = $item->payloadConfig();
33
        }
34
        return $payload;
35
    }
36
}
37