Completed
Push — master ( dd6b15...3be450 )
by Cedric
02:47
created

ContentService::findById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of the Adlogix package.
4
 *
5
 * (c) Allan Segebarth <[email protected]>
6
 * (c) Jean-Jacques Courtens <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Adlogix\ConfluenceClient\Service;
13
14
use Adlogix\ConfluenceClient\Entity\Collection\ContentCollection;
15
use Adlogix\ConfluenceClient\Entity\Content;
16
17
/**
18
 * Class PageService
19
 * @package Adlogix\ConfluenceClient\Service
20
 * @author  Cedric Michaux <[email protected]>
21
 */
22
class ContentService extends AbstractApiService
23
{
24
25
    /**
26
     * @param string $spaceKey
27
     * @param array  $options
28
     *
29
     * @return ContentCollection|null
30
     */
31
    public function all($spaceKey = "", array $options = [])
32
    {
33
34
        if (!empty($spaceKey)) {
35
            $options = $this->mergeQueryOptions($options, [
36
                "query" => [
37
                    "spaceKey" => $spaceKey
38
                ]
39
            ]);
40
        }
41
42
        $all = $this->get('content', $options);
43
        return $this->deserialize(
44
            $all,
45
            ContentCollection::class
46
        );
47
48
    }
49
50
51
    /**
52
     * @param $id
53
     *
54
     * @return mixed
55
     */
56
    public function findById($id)
57
    {
58
        $content = $this->get('content/' . $id);
59
        return $this->deserialize(
60
            $content,
61
            Content::class
62
        );
63
    }
64
65
}
66