Vtu::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Djunehor\Vtu\Concrete;
4
5
use Djunehor\Vtu\Contracts\VtuServiceInterface;
6
use GuzzleHttp\Client;
7
8
abstract class Vtu implements VtuServiceInterface
9
{
10
    protected $text;
11
    protected $username;
12
    protected $password;
13
    protected $recipients = [];
14
    private static $httpClient;
15
    protected $sender;
16
    protected $response;
17
    protected $client;
18
    protected $request;
19
20
    /**
21
     * @var \Exception
22
     */
23
    public $httpError;
24
25
    /**We want HTTP CLient instantiated
26
     * only once in entire app lifecycle
27
     * @return Client
28
     */
29 5
    public static function getInstance()
30
    {
31 5
        if (! self::$httpClient) {
32 5
            self::$httpClient = new Client();
33
        }
34
35 5
        return self::$httpClient;
36
    }
37
38
39
    /**We want HTTP CLient instantiated
40
     * only once in entire app lifecycle
41
     * @return string $response
42
     */
43
    public function getResponse() : string
44
    {
45
        return $this->response;
46
    }
47
48
    public function getException() : \Exception
49
    {
50
        return $this->httpError;
51
    }
52
53 2
    public function getUsername()
54
    {
55 2
        return $this->username;
56
    }
57
58
}
59