ToOne   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 3
eloc 12
c 2
b 0
f 2
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 17 2
A __construct() 0 2 1
1
<?php
2
3
namespace MeysamZnd\HostiranSmsProvider;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\Exception\GuzzleException;
7
use MeysamZnd\HostiranSmsProvider\Interfaces\Sms;
8
9
class ToOne implements Sms
10
{
11
    public function __construct()
12
    {
13
    }
14
15
    /**
16
     * @param string $url
17
     * @param array $data
18
     * @return array
19
     * @throws GuzzleException
20
     */
21
    public function send(string $url, array $data): array
22
    {
23
        try {
24
            $client = new Client();
25
            $request = $client->post($url, ['json' => $data]);
26
            $response = [
27
                'status' => true,
28
                'providerResult' => json_decode($request->getBody()->getContents(), true),
29
            ];
30
        } catch (\Exception $e) {
31
            $response = [
32
                'status' => false,
33
                'providerResult' => $e->getMessage(),
34
            ];
35
        }
36
37
        return $response;
38
    }
39
}
40