Chatwork::my()   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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Polidog\Chatwork;
6
7
use Polidog\Chatwork\Api\Contacts;
8
use Polidog\Chatwork\Api\Me;
9
use Polidog\Chatwork\Api\My;
10
use Polidog\Chatwork\Api\Rooms;
11
use Polidog\Chatwork\Client\Client;
12
use Polidog\Chatwork\Client\ClientFactory;
13
use Polidog\Chatwork\Client\ClientInterface;
14
use Polidog\Chatwork\Entity\Factory\RoomFactory;
15
use Polidog\Chatwork\Entity\Factory\UserFactory;
16
17
class Chatwork
18
{
19
    /**
20
     * @var ClientInterface
21
     */
22
    private $client;
23
24
    /**
25
     * Chatwork constructor.
26
     *
27
     * @param ClientInterface $client
28
     */
29
    public function __construct(ClientInterface $client)
30
    {
31
        $this->client = $client;
32
    }
33
34
    public function me(): Me
35
    {
36
        return new Api\Me($this->client, new UserFactory());
37
    }
38
39
    public function my(): My
40
    {
41
        return new Api\My($this->client);
42
    }
43
44
    public function contacts(): Contacts
45
    {
46
        return new Api\Contacts($this->client, new UserFactory());
47
    }
48
49
    public function rooms(): Rooms
50
    {
51
        return new Api\Rooms($this->client, new RoomFactory());
52
    }
53
54
    public static function create(string $token, string $version = 'v2'): self
55
    {
56
        return new self(new Client($token, $version, null));
57
    }
58
}
59