SenderProperty::getSender()   A
last analyzed

Complexity

Conditions 6
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 9.2222
c 1
b 0
f 0
1
<?php
2
3
namespace Daaner\NovaPoshta\Traits;
4
5
trait SenderProperty
6
{
7
    protected $Sender;
8
    protected $CitySender;
9
    protected $SenderAddress;
10
    protected $ContactSender;
11
    protected $SendersPhone;
12
13
    /**
14
     * Устанавливаем значение отправителя. Если не указывать - значение конфига.
15
     *
16
     * @param  array  $sender  Тип отправителя массивом
17
     * @return $this
18
     */
19
    public function setSender(array $sender): self
20
    {
21
        if (isset($sender['Sender'])) {
22
            $this->Sender = $sender['Sender'] ?? null;
23
            $this->CitySender = $sender['CitySender'] ?? null;
24
            $this->SenderAddress = $sender['SenderAddress'] ?? null;
25
            $this->ContactSender = $sender['ContactSender'] ?? null;
26
            $this->SendersPhone = $sender['SendersPhone'] ?? null;
27
        }
28
29
        return $this;
30
    }
31
32
    /**
33
     * @return void
34
     */
35
    public function getSender(): void
36
    {
37
        $this->methodProperties['Sender'] = $this->Sender ?: config('novaposhta.sender');
38
        $this->methodProperties['CitySender'] = $this->CitySender ?: config('novaposhta.city_sender');
39
        $this->methodProperties['SenderAddress'] = $this->SenderAddress ?: config('novaposhta.sender_address');
40
        $this->methodProperties['ContactSender'] = $this->ContactSender ?: config('novaposhta.contact_sender');
41
        $this->methodProperties['SendersPhone'] = $this->SendersPhone ?: config('novaposhta.senders_phone');
42
    }
43
}
44