Completed
Push — master ( 37d52e...ca4941 )
by Jhao
11:04
created

CalculationRequest   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 16
eloc 34
c 1
b 0
f 0
dl 0
loc 113
rs 10

16 Methods

Rating   Name   Duplication   Size   Complexity  
A ofMailType() 0 5 1
A fragile() 0 5 1
A ofMailCategory() 0 5 1
A ofEntriesType() 0 5 1
A create() 0 3 1
A withCompletenessChecking() 0 5 1
A __construct() 0 5 1
A withDeclaredValue() 0 5 1
A dimensions() 0 5 1
A viaCourier() 0 5 1
A withContentChecking() 0 5 1
A withElectronicNotice() 0 5 1
A withRegisteredNotice() 0 5 1
A withInventory() 0 5 1
A withSmsNotice() 0 5 1
A withSimpleNotice() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Requests;
6
7
use Appwilio\RussianPostSDK\Dispatching\DataAware;
8
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable;
9
10
final class CalculationRequest implements Arrayable
11
{
12
    use DataAware;
13
14
    public static function create(string $to, int $weight): self
15
    {
16
        return new self(...\func_get_args());
17
    }
18
19
    public function __construct(string $to, int $weight)
20
    {
21
        $this->data = [
22
            'index-to' => $to,
23
            'mass'     => $weight,
24
        ];
25
    }
26
27
    public function ofEntriesType(string $entriesType)
28
    {
29
        $this->data['entries-type'] = $entriesType;
30
31
        return $this;
32
    }
33
34
    public function ofMailCategory(string $mailCategory)
35
    {
36
        $this->data['mail-category'] = $mailCategory;
37
38
        return $this;
39
    }
40
41
    public function ofMailType(string $mailType)
42
    {
43
        $this->data['mail-type'] = $mailType;
44
45
        return $this;
46
    }
47
48
    public function dimensions(int $height, int $width, int $length)
49
    {
50
        $this->data['dimension'] = \compact('height', 'width', 'length');
51
52
        return $this;
53
    }
54
55
    public function fragile(bool $value = true)
56
    {
57
        $this->data['fragile'] = $value;
58
59
        return $this;
60
    }
61
62
    public function viaCourier(bool $value = true)
63
    {
64
        $this->data['courier'] = $value;
65
66
        return $this;
67
    }
68
69
    public function withDeclaredValue(int $value)
70
    {
71
        $this->data['declared-value'] = $value;
72
73
        return $this;
74
    }
75
76
    public function withCompletenessChecking(bool $value = true)
77
    {
78
        $this->data['completeness-checking'] = $value;
79
80
        return $this;
81
    }
82
83
    public function withContentChecking(bool $value = true)
84
    {
85
        $this->data['conntent-checking'] = $value;
86
87
        return $this;
88
    }
89
90
    public function withInventory(bool $value = true)
91
    {
92
        $this->data['inventory'] = $value;
93
94
        return $this;
95
    }
96
97
    public function withElectronicNotice(bool $value = true)
98
    {
99
        $this->data['with-electronic-notice'] = $value;
100
101
        return $this;
102
    }
103
104
    public function withSimpleNotice(bool $value = true)
105
    {
106
        $this->data['with-simple-notice'] = $value;
107
108
        return $this;
109
    }
110
111
    public function withRegisteredNotice(bool $value = true)
112
    {
113
        $this->data['with-order-of-notice'] = $value;
114
115
        return $this;
116
    }
117
118
    public function withSmsNotice(bool $value = true)
119
    {
120
        $this->data['sms-notice-recipient'] = $value;
121
122
        return $this;
123
    }
124
}
125