Passed
Push — master ( 5dcfca...b6bddc )
by Andrey
03:35
created

AdditionalServiceProperty::getReturnAddressRef()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Daaner\NovaPoshta\Traits;
4
5
trait AdditionalServiceProperty
6
{
7
    protected $Reason;
8
    protected $SubtypeReason;
9
    protected $ReturnAddressRef;
10
    protected $RecipientWarehouse;
11
    protected $RecipientSettlement;
12
13
14
    /**
15
     * @return void
16
     */
17
    public function getReason(): void
18
    {
19
        $this->methodProperties['Reason'] = $this->Reason ?: config('novaposhta.ref_return_reasons');
20
    }
21
22
    /**
23
     * Устанавливаем идентификатор причины возврата.
24
     *
25
     * @param  string  $Reason
26
     * @return void
27
     */
28
    public function setReason(string $Reason): void
29
    {
30
        $this->Reason = $Reason;
31
    }
32
33
    /**
34
     * @return void
35
     */
36
    public function getSubtypeReason(): void
37
    {
38
        $this->methodProperties['SubtypeReason'] = $this->SubtypeReason ?: config('novaposhta.ref_return_reasons_sub');
39
    }
40
41
    /**
42
     * Устанавливаем идентификатор причины суб возврата.
43
     *
44
     * @param  string  $SubtypeReason
45
     * @return void
46
     */
47
    public function setSubtypeReason(string $SubtypeReason): void
48
    {
49
        $this->SubtypeReason = $SubtypeReason;
50
    }
51
52
    /**
53
     * @return void
54
     */
55
    public function getReturnAddressRef(): void
56
    {
57
        if ($this->ReturnAddressRef) {
58
            $this->methodProperties['ReturnAddressRef'] = $this->ReturnAddressRef;
59
        }
60
    }
61
62
    /**
63
     * Устанавливаем идентификатор адреса возврата.
64
     * Значение из метода CheckPossibilityCreateReturn!!!
65
     *
66
     * @param  string  $ReturnAddressRef
67
     * @return void
68
     */
69
    public function setReturnAddressRef(string $ReturnAddressRef): void
70
    {
71
        $this->ReturnAddressRef = $ReturnAddressRef;
72
73
        // Очищаем данные предыдущих значений по возврату
74
        $this->RecipientWarehouse = null;
75
        $this->RecipientSettlement = null;
76
    }
77
78
    /**
79
     * @return void
80
     */
81
    public function getRecipientWarehouse(): void
82
    {
83
        if ($this->RecipientWarehouse) {
84
            $this->methodProperties['RecipientWarehouse'] = $this->RecipientWarehouse;
85
        }
86
87
        //Если другие идентификаторы не заполнены - оформляем возврат на отделение по умолчанию (из конфига)
88
        if (! $this->ReturnAddressRef && ! $this->RecipientWarehouse && ! $this->RecipientSettlement) {
89
            $this->methodProperties['RecipientWarehouse'] = config('novaposhta.ref_return_warehouse');
90
        }
91
    }
92
93
    /**
94
     * Устанавливаем идентификатор возврата на новое отделение.
95
     *
96
     * @param  string  $RecipientWarehouse
97
     * @return void
98
     */
99
    public function setRecipientWarehouse(string $RecipientWarehouse): void
100
    {
101
        $this->RecipientWarehouse = $RecipientWarehouse;
102
103
        // Очищаем данные предыдущих значений по возврату
104
        $this->ReturnAddressRef = null;
105
        $this->RecipientSettlement = null;
106
    }
107
108
    /**
109
     * @return void
110
     */
111
    public function getRecipientSettlement(): void
112
    {
113
        if ($this->RecipientSettlement) {
114
            $this->methodProperties['RecipientSettlement'] = $this->RecipientSettlement['settlement'] ?? '';
115
            $this->methodProperties['RecipientSettlementStreet'] = $this->RecipientSettlement['street'] ?? '';
116
            $this->methodProperties['BuildingNumber'] = $this->RecipientSettlement['building'] ?? '';
117
            $this->methodProperties['NoteAddressRecipient'] = $this->RecipientSettlement['other'] ?? '';
118
        }
119
    }
120
121
    /**
122
     * Устанавливаем идентификатор возврата на новое отделение.
123
     *
124
     * @param array $RecipientSettlement
125
     * @return void
126
     */
127
    public function setRecipientSettlement(array $RecipientSettlement): void
128
    {
129
        $this->RecipientSettlement = $RecipientSettlement;
130
131
        // Очищаем данные предыдущих значений по возврату
132
        $this->ReturnAddressRef = null;
133
        $this->RecipientWarehouse = null;
134
    }
135
136
}
137