Passed
Push — master ( f1ff91...53e7cc )
by Romain
59s
created

Tag   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 3
dl 0
loc 45
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getInstance() 0 8 2
A get() 0 7 1
1
<?php
2
3
namespace Kerox\Messenger\Api;
4
5
use GuzzleHttp\ClientInterface;
6
use Kerox\Messenger\Request\TagRequest;
7
use Kerox\Messenger\Response\TagResponse;
8
9
class Tag extends AbstractApi
10
{
11
12
    /**
13
     * @var null|\Kerox\Messenger\Api\Tag
14
     */
15
    private static $_instance;
16
17
    /**
18
     * Tag constructor.
19
     *
20
     * @param string $pageToken
21
     * @param \GuzzleHttp\ClientInterface $client
22
     */
23 2
    public function __construct(string $pageToken, ClientInterface $client)
24
    {
25 2
        parent::__construct($pageToken, $client);
26 2
    }
27
28
    /**
29
     * @param string $pageToken
30
     * @param \GuzzleHttp\ClientInterface $client
31
     *
32
     * @return \Kerox\Messenger\Api\Tag
33
     */
34 1
    public static function getInstance(string $pageToken, ClientInterface $client): Tag
35
    {
36 1
        if (self::$_instance === null) {
37 1
            self::$_instance = new Tag($pageToken, $client);
38
        }
39
40 1
        return self::$_instance;
41
    }
42
43
    /**
44
     * @return \Kerox\Messenger\Response\TagResponse
45
     */
46 1
    public function get(): TagResponse
47
    {
48 1
        $request = new TagRequest($this->pageToken);
49 1
        $response = $this->client->get('page_message_tags', $request->build());
50
51 1
        return new TagResponse($response);
52
    }
53
}
54