Gift::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers\Trees;
4
5
use App\Http\Controllers\Controller;
6
use iWebTouch\Gelato\Gelato;
7
8
class Gift extends Controller
9
{
10
    public function __construct(private readonly Gelato $shop)
11
    {
12
    }
13
14
    public function createOrder()
15
    {
16
        $shipTo = [
17
            'companyName' => 'No Name',
18
            'firstName' => 'John',                  // required
19
            'lastName' => 'Doe',                  // required
20
            'addressLine1' => '451 Clarkson Ave',   // required
21
            'addressLine2' => 'Brooklyn',
22
            'state' => 'NY',
23
            'city' => 'New York',                   // required
24
            'postCode' => '11203',                  // required
25
            'country' => 'US',                      // required
26
            'email' => '[email protected]',         // required
27
            'phone' => '123456789',
28
        ];
29
30
        $item = [
31
            'itemReferenceId' => 'ITEM-123',
32
            'productUid' => 'framed_poster_130x180-mm-5x7-inch_black_wood_w12xt22-mm_plexiglass_130x180-mm-5r_170-gsm-65lb-coated-silk_4-0_hor',
33
            'fileUrl' => 'https://github.githubassets.com/images/modules/logos_page/Octocat.png',
34
            'quantity' => 1,
35
        ];
36
37
        $this->shop->setOrderData('ORDER-456', 'CUST-002', 'USD')
38
                    ->addItem($item)
39
                    ->setShippingAddress($shipTo);
40
41
        return $this->shop->createOrder();
42
    }
43
44
    public function getOrder(string $orderId)
45
    {
46
        return $this->shop->getOrder($orderId);
47
    }
48
49
    public function getShippingAddress(string $orderId)
50
    {
51
        return $this->shop->getShippingAddress($orderId);
52
    }
53
}
54