Completed
Push — 3.x ( e32815...7c4255 )
by Ryota
10:41 queued 09:27
created

Chatwork   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 7
dl 0
loc 42
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A me() 0 4 1
A my() 0 4 1
A contacts() 0 4 1
A rooms() 0 4 1
A create() 0 4 1
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\ClientFactory;
12
use Polidog\Chatwork\Client\ClientInterface;
13
use Polidog\Chatwork\Entity\Factory\RoomFactory;
14
use Polidog\Chatwork\Entity\Factory\UserFactory;
15
16
class Chatwork
17
{
18
    /**
19
     * @var ClientInterface
20
     */
21
    private $client;
22
23
    /**
24
     * Chatwork constructor.
25
     *
26
     * @param ClientInterface $client
27
     */
28
    public function __construct(ClientInterface $client)
29
    {
30
        $this->client = $client;
31
    }
32
33
    public function me(): Me
34
    {
35
        return new Api\Me($this->client, new UserFactory());
36
    }
37
38
    public function my(): My
39
    {
40
        return new Api\My($this->client);
41
    }
42
43
    public function contacts(): Contacts
44
    {
45
        return new Api\Contacts($this->client, new UserFactory());
46
    }
47
48
    public function rooms(): Rooms
49
    {
50
        return new Api\Rooms($this->client, new RoomFactory());
51
    }
52
53
    public static function create(string $token, string $version = 'v2', array $httpOptions = []): self
54
    {
55
        return new self(ClientFactory::create($token, $version, $httpOptions));
56
    }
57
}
58