Passed
Push — master ( 302558...609380 )
by Jared
51s
created

Ping::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace CultureKings\Afterpay\Service;
3
4
use CultureKings\Afterpay\Traits\ClientTrait;
5
use Exception;
6
use GuzzleHttp\Client;
7
8
/**
9
 * Class Ping
10
 * @package CultureKings\Afterpay\Service\InStore
11
 */
12
class Ping
13
{
14
    use ClientTrait;
15
16
    /**
17
     * Ping constructor.
18
     *
19
     * @param Client $client
20
     */
21
    public function __construct(Client $client)
22
    {
23
        $this->setClient($client);
24
    }
25
26
    /**
27
     * Attempt to access the ping endpoint and will return true on success.
28
     * @return bool
29
     */
30
    public function ping()
31
    {
32
        try {
33
            $this->getClient()->get('ping');
34
            return true;
35
        } catch (Exception $e) {
36
            return false;
37
        }
38
    }
39
40
}
41