Completed
Pull Request — master (#10)
by Laurens
02:51
created

Settings::new()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\API\Inventory;
6
7
use LauLamanApps\IzettleApi\API\Inventory\Settings\NotificationSettings;
8
use LauLamanApps\IzettleApi\API\Universal\iZettlePostable;
9
10
final class Settings implements iZettlePostable
11
{
12
    private $etag;
13
    private $defaultRefundToLocation;
14
    private $notificationSettings;
15
16
    public function new(
17
        string $defaultRefundToLocation,
18
        NotificationSettings $notificationSettings
19
    ): self {
20
        return new self(null, $defaultRefundToLocation, $notificationSettings);
21
    }
22
23
    public function create(
24
        string $etag,
25
        string $defaultRefundToLocation,
26
        NotificationSettings $notificationSettings
27
    ): self {
28
        return new self($etag, $defaultRefundToLocation, $notificationSettings);
29
    }
30
31
    public function getEtag(): ?string
32
    {
33
        return $this->etag;
34
    }
35
36
    public function getDefaultRefundToLocation(): string
37
    {
38
        return $this->defaultRefundToLocation;
39
    }
40
41
    public function getNotificationSettings(): NotificationSettings
42
    {
43
        return $this->notificationSettings;
44
    }
45
46
    public function getPostData(): array
47
    {
48
        return [
49
                "defaultRefundToLocation" => $this->defaultRefundToLocation,
50
                "notificationSettings" => $this->notificationSettings->getPostData()
51
        ];
52
    }
53
54
    private function __construct(
55
        ?string $etag = null,
56
        string $defaultRefundToLocation,
57
        NotificationSettings $notificationSettings
58
    ) {
59
        $this->etag = $etag;
60
        $this->defaultRefundToLocation = $defaultRefundToLocation;
61
        $this->notificationSettings = $notificationSettings;
62
    }
63
}
64