Total Complexity | 9 |
Total Lines | 118 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class FortySixElksMedia |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | const ENDPOINT = null; |
||
14 | /** |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $payload = [ |
||
18 | 'lines' => [], |
||
19 | 'subject' => '', |
||
20 | ]; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | */ |
||
25 | protected $phone_number; |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $from; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $username; |
||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $password; |
||
39 | |||
40 | /** |
||
41 | * FortySixElksMedia constructor. |
||
42 | */ |
||
43 | public function __construct() |
||
44 | { |
||
45 | $this->username = config('services.46elks.username'); |
||
46 | $this->password = config('services.46elks.password'); |
||
47 | if (!$this->username || !$this->password) { |
||
48 | throw MissingConfigNotification::missingConfig(); |
||
49 | } |
||
50 | |||
51 | $this->client = new Client( |
||
|
|||
52 | [ |
||
53 | 'headers' => [ |
||
54 | 'Content-Type' => 'application/x-www-urlencoded', |
||
55 | ], |
||
56 | 'auth' => [ |
||
57 | $this->username, |
||
58 | $this->password, |
||
59 | ], |
||
60 | ] |
||
61 | ); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @param $line |
||
66 | * |
||
67 | * @return $this |
||
68 | */ |
||
69 | public function line($line) |
||
70 | { |
||
71 | $this->payload['lines'][] = $line; |
||
72 | |||
73 | return $this; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param $subject |
||
78 | * |
||
79 | * @return $this |
||
80 | */ |
||
81 | public function subject($subject) |
||
82 | { |
||
83 | $this->payload['subject'] = $subject; |
||
84 | |||
85 | return $this; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @param $phone_number |
||
90 | * |
||
91 | * @return $this |
||
92 | */ |
||
93 | public function to($phoneNumber) |
||
94 | { |
||
95 | $this->phone_number = $phoneNumber; |
||
96 | |||
97 | return $this; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * @param $string |
||
102 | * |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function from($string) |
||
106 | { |
||
107 | $this->from = $string; |
||
108 | |||
109 | return $this; |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @return string |
||
114 | */ |
||
115 | public function getContent() |
||
116 | { |
||
117 | return implode(PHP_EOL, $this->payload['lines']); |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * @return mixed |
||
122 | */ |
||
123 | public function getSubject() |
||
126 | } |
||
127 | } |
||
128 |