Completed
Push — master ( 0512a1...7c8694 )
by Tomáš
03:46
created

CommonData::offsetGet()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
ccs 0
cts 0
cp 0
nc 1
1
<?php
2
3
namespace Inspirum\Balikobot\Model\Values\Package;
4
5
use Inspirum\Balikobot\Definitions\Option;
6
7
trait CommonData
8
{
9
    /**
10
     * Set the item at a given offset
11
     *
12
     * @param string $key
13
     * @param mixed  $value
14
     *
15
     * @return void
16
     */
17
    abstract public function offsetSet($key, $value);
18
19
    /**
20
     * Get an item at a given offset
21
     *
22
     * @param string $key
23
     *
24
     * @return mixed
25
     */
26
    abstract public function offsetGet($key);
27
28
    /**
29
     * Determine if an item exists at an offset
30
     *
31
     * @param string $key
32
     *
33
     * @return bool
34
     */
35
    abstract public function offsetExists($key);
36
37
    /**
38
     * Set EID
39
     *
40
     * @param string $id
41
     *
42
     * @return void
43
     */
44 6
    public function setEID(string $id): void
45
    {
46 6
        $this->offsetSet(Option::EID, $id);
47 6
    }
48
49
    /**
50
     * Get EID
51
     *
52
     * @return string|null
53
     */
54 17
    public function getEID(): ?string
55
    {
56 17
        return $this->offsetGet(Option::EID);
57
    }
58
59
    /**
60
     * Get EID
61
     *
62
     * @return bool
63
     */
64 21
    public function hasEID(): bool
65
    {
66 21
        return $this->offsetExists(Option::EID);
67
    }
68
69
    /**
70
     * @param int $orderNumber
71
     *
72
     * @return void
73
     */
74 1
    public function setOrderNumber(int $orderNumber): void
75
    {
76 1
        $this->offsetSet(Option::ORDER_NUMBER, $orderNumber);
77 1
    }
78
79
    /**
80
     * @param string $realOrderId
81
     *
82
     * @return void
83
     */
84 1
    public function setRealOrderId(string $realOrderId): void
85
    {
86 1
        $this->offsetSet(Option::REAL_ORDER_ID, $realOrderId);
87 1
    }
88
89
    /**
90
     * @param string $serviceType
91
     *
92
     * @return void
93
     */
94 2
    public function setServiceType(string $serviceType): void
95
    {
96 2
        $this->offsetSet(Option::SERVICE_TYPE, $serviceType);
97 2
    }
98
99
    /**
100
     * @param array<string> $services
101
     *
102
     * @return void
103
     */
104 1
    public function setServices(array $services): void
105
    {
106
        // TODO: add validation
107
108 1
        $this->offsetSet(Option::SERVICES, implode('+', $services));
109 1
    }
110
111
    /**
112
     * @param string $branchId
113
     *
114
     * @return void
115
     */
116 1
    public function setBranchId(string $branchId): void
117
    {
118 1
        $this->offsetSet(Option::BRANCH_ID, $branchId);
119 1
    }
120
121
    /**
122
     * @param bool $fullErrors
123
     *
124
     * @return void
125
     */
126 1
    public function setReturnFullErrors(bool $fullErrors = true): void
127
    {
128 1
        $this->offsetSet(Option::RETURN_FULL_ERRORS, (int) $fullErrors);
129 1
    }
130
131
    /**
132
     * @param bool $returnTrack
133
     *
134
     * @return void
135
     */
136 1
    public function setReturnTrack(bool $returnTrack = true): void
137
    {
138 1
        $this->offsetSet(Option::RETURN_TRACK, (int) $returnTrack);
139 1
    }
140
141
    /**
142
     * @param bool $returnCarrierId
143
     *
144
     * @return void
145
     */
146 1
    public function setReturnFinalCarrierId(bool $returnCarrierId = true): void
147
    {
148 1
        $this->offsetSet(Option::RETURN_FINAL_CARRIER_ID, (int) $returnCarrierId);
149 1
    }
150
}
151