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

Files::detail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Polidog\Chatwork\Api\Rooms;
6
7
use Polidog\Chatwork\Client\ClientInterface;
8
use Polidog\Chatwork\Entity\Collection\CollectionInterface;
9
use Polidog\Chatwork\Entity\Factory\FileFactory;
10
use Polidog\Chatwork\Entity\File;
11
12
/**
13
 * Class Files.
14
 */
15
class Files
16
{
17
    /**
18
     * @var ClientInterface
19
     */
20
    private $client;
21
22
    /**
23
     * @var FileFactory
24
     */
25
    private $factory;
26
27
    /**
28
     * @var int
29
     */
30
    private $roomId;
31
32
    /**
33
     * Files constructor.
34
     *
35
     * @param ClientInterface $client
36
     * @param FileFactory     $factory
37
     * @param int             $roomId
38
     */
39
    public function __construct(ClientInterface $client, FileFactory $factory, int $roomId)
40
    {
41
        $this->client = $client;
42
        $this->factory = $factory;
43
        $this->roomId = $roomId;
44
    }
45
46
    /**
47
     * @param null $accountId
48
     *
49
     * @return CollectionInterface
50
     */
51
    public function show($accountId = null)
52
    {
53
        $options = [
54
        ];
55
56
        if (!is_null($accountId)) {
57
            $options['account_id'] = $accountId;
58
        }
59
60
        return $this->factory->collection(
61
            $this->client->get(
62
                "rooms/{$this->roomId}/files",
63
                $options
64
            )
65
        );
66
    }
67
68
    /**
69
     * @param $id
70
     *
71
     * @return File
72
     */
73
    public function detail($id)
74
    {
75
        return $this->factory->entity(
76
          $this->client->get(
77
              "rooms/{$this->roomId}/files/{$id}"
78
          )
79
        );
80
    }
81
}
82