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

IncomingRequests   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 43
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A show() 0 6 1
A accept() 0 6 1
A reject() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Polidog\Chatwork\Api;
6
7
use Polidog\Chatwork\Client\ClientInterface;
8
use Polidog\Chatwork\Entity\Factory\IncomingRequestsFactory;
9
10
class IncomingRequests
11
{
12
    /**
13
     * @var ClientInterface
14
     */
15
    private $client;
16
17
    /**
18
     * @var IncomingRequestsFactory
19
     */
20
    private $factory;
21
22
    /**
23
     * IncomingRequests constructor.
24
     *
25
     * @param ClientInterface         $client
26
     * @param IncomingRequestsFactory $factory
27
     */
28
    public function __construct(ClientInterface $client, IncomingRequestsFactory $factory)
29
    {
30
        $this->client = $client;
31
        $this->factory = $factory;
32
    }
33
34
    public function show()
35
    {
36
        return $this->factory->collection(
37
            $this->client->get('incoming_requests')
38
        );
39
    }
40
41
    public function accept($requestId)
42
    {
43
        return $this->factory->entity(
44
            $this->client->put("incoming_requests/{$requestId}")
45
        );
46
    }
47
48
    public function reject($requestId)
49
    {
50
        $this->client->delete("incoming_requests/{$requestId}");
51
    }
52
}
53