Passed
Pull Request — master (#62)
by Romain
02:05
created

Thread::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Kerox\Messenger\Api;
4
5
use GuzzleHttp\ClientInterface;
6
use Kerox\Messenger\Model\ThreadControl;
7
use Kerox\Messenger\Request\ThreadRequest;
8
use Kerox\Messenger\Response\ThreadResponse;
9
10
class Thread extends AbstractApi
11
{
12
    /**
13
     * @var null|\Kerox\Messenger\Api\User
14
     */
15
    private static $_instance;
16
17
    /**
18
     * Send constructor.
19
     *
20
     * @param string                      $pageToken
21
     * @param \GuzzleHttp\ClientInterface $client
22
     */
23 3
    public function __construct(string $pageToken, ClientInterface $client)
24
    {
25 3
        parent::__construct($pageToken, $client);
26 3
    }
27
28
    /**
29
     * @param string                      $pageToken
30
     * @param \GuzzleHttp\ClientInterface $client
31
     *
32
     * @return \Kerox\Messenger\Api\Thread
33
     */
34 1
    public static function getInstance(string $pageToken, ClientInterface $client): Thread
35
    {
36 1
        if (self::$_instance === null) {
37 1
            self::$_instance = new self($pageToken, $client);
0 ignored issues
show
Documentation Bug introduced by
It seems like new self($pageToken, $client) of type object<Kerox\Messenger\Api\Thread> is incompatible with the declared type null|object<Kerox\Messenger\Api\User> of property $_instance.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
38
        }
39
40 1
        return self::$_instance;
41
    }
42
43
    /**
44
     * @param \Kerox\Messenger\Model\ThreadControl $threadControl
45
     *
46
     * @return \Kerox\Messenger\Response\ThreadResponse
47
     */
48 1
    public function pass(ThreadControl $threadControl): ThreadResponse
49
    {
50 1
        $request = new ThreadRequest($this->pageToken, $threadControl);
51 1
        $response = $this->client->post('me/pass_thread_control', $request->build());
52
53 1
        return new ThreadResponse($response);
54
    }
55
56
    /**
57
     * @param \Kerox\Messenger\Model\ThreadControl $threadControl
58
     *
59
     * @return \Kerox\Messenger\Response\ThreadResponse
60
     */
61 1
    public function take(ThreadControl $threadControl): ThreadResponse
62
    {
63 1
        $request = new ThreadRequest($this->pageToken, $threadControl);
64 1
        $response = $this->client->post('me/take_thread_control', $request->build());
65
66 1
        return new ThreadResponse($response);
67
    }
68
}
69