HttpClientTrait::setHttpClient()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
namespace Health\Checks\Traits;
3
4
use GuzzleHttp\Client;
5
6
/**
7
 * Http Client Instance
8
 */
9
trait HttpClientTrait
10
{
11
12
    /**
13
     *
14
     * @var Client
15
     */
16
    protected $client;
17
18
    /**
19
     *
20
     * @param Client $client
21
     */
22
    public function setHttpClient(Client $client)
23
    {
24
        $this->client = $client;
25
    }
26
27
    /**
28
     *
29
     * @return \GuzzleHttp\Client
30
     */
31
    protected function getHttpClient()
32
    {
33
        if (! $this->client) {
34
            $this->client = new Client();
35
        }
36
37
        return $this->client;
38
    }
39
}
40