Passed
Push — master ( 92054c...3577c6 )
by Andrey
04:17
created

OptionsSeatProperty::getOptionsSeat()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Daaner\NovaPoshta\Traits;
4
5
trait OptionsSeatProperty
6
{
7
    protected $OptionsSeat;
8
9
10
    /**
11
     * @param string||array $OptionsSeat
0 ignored issues
show
Documentation Bug introduced by
The doc comment string||array at position 2 could not be parsed: Unknown type name '|' at position 2 in string||array.
Loading history...
12
     * Параметр груза для каждого места отправления
13
     * Перебираем значение массива и вказываем нужные объемы
14
     * Если не указывать значение из конфига в 1 кг
15
     * @see https://devcenter.novaposhta.ua/docs/services/556eef34a0fe4f02049c664e/operations/57484280a0fe4f33f0d4dd77
16
     * @return this
17
     */
18
    public function setOptionsSeat($OptionsSeat)
19
    {
20
        $data = config('novaposhta.options_seat');
21
        if (is_array($OptionsSeat) === false) {
22
            $OptionsSeat = explode(',', /** @scrutinizer ignore-type */ $OptionsSeat);
23
        }
24
        foreach ($OptionsSeat as $key => $value) {
25
            try {
26
                $this->OptionsSeat[] = $data[$value];
27
            } catch (\Exception $e) {
28
                $this->OptionsSeat[] = $data[1];
29
            }
30
        }
31
32
        return $this;
33
    }
34
35
    public function getOptionsSeat()
36
    {
37
        if (! $this->OptionsSeat) {
38
            $this->OptionsSeat[] = config('novaposhta.options_seat')[10];
39
        }
40
        $this->methodProperties['OptionsSeat'] = $this->OptionsSeat;
1 ignored issue
show
Bug Best Practice introduced by
The property methodProperties does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
41
42
        return $this;
43
    }
44
45
46
    /**
47
     * @param string $Weight
48
     * Устанавливаем вес груза. По умолчанию значение из конфига
49
     * nit:Daan
50
     * Не обязательно, если выставляем OptionsSeat, но пока оставлю тут
51
     * @return this
52
     */
53
    public function setWeight($Weight)
54
    {
55
        $this->Weight = $Weight;
0 ignored issues
show
Bug Best Practice introduced by
The property Weight does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
56
57
        return $this;
58
    }
59
60
    public function getWeight()
61
    {
62
        if (! $this->Weight) {
63
            $this->Weight = config('novaposhta.weight');
0 ignored issues
show
Bug Best Practice introduced by
The property Weight does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
64
        }
65
        $this->methodProperties['Weight'] = $this->Weight;
1 ignored issue
show
Bug Best Practice introduced by
The property methodProperties does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
66
67
        return $this;
68
    }
69
70
}
71