Completed
Push — master ( 0aaac1...5f7917 )
by dotzero
02:41
created

FlowResource   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 76
ccs 18
cts 18
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFlows() 0 4 1
A getFeedInteresting() 0 7 1
A getFeedAll() 0 7 1
A getFeedBest() 0 7 1
A getHubList() 0 7 1
1
<?php
2
3
namespace Habrahabr\Api\Resources;
4
5
use Habrahabr\Api\Exception\IncorrectUsageException;
6
7
/**
8
 * Class FlowResource
9
 *
10
 * Ресурс работы с потоками
11
 *
12
 * @package Habrahabr\Api\Resources
13
 * @version 0.1.0
14
 * @author thematicmedia <[email protected]>
15
 * @link https://tmtm.ru/
16
 * @link https://habrahabr.ru/
17
 * @link https://github.com/thematicmedia/habrahabr_api
18
 *
19
 * For the full copyright and license information, please view the LICENSE
20
 * file that was distributed with this source code.
21
 */
22
class FlowResource extends AbstractResource implements ResourceInterface
23
{
24
    /**
25
     * Возвращает список потоков
26
     *
27
     * @return array
28
     */
29 1
    public function getFlows()
30
    {
31 1
        return $this->adapter->get('/flows');
32
    }
33
34
    /**
35
     * Возвращает "Интересные" посты из потока
36
     *
37
     * @param string $alias Алиаса потока
38
     * @param int $page Номер страницы
39
     * @return array
40
     * @throws IncorrectUsageException
41
     */
42 1
    public function getFeedInteresting($alias, $page = 1)
43
    {
44 1
        $this->checkAliasName($alias);
45 1
        $this->checkPageNumber($page);
46
47 1
        return $this->adapter->get(sprintf('/flows/%s/interesting?page=%d', $alias, $page));
48
    }
49
50
    /**
51
     * Возвращает "Все" посты посты из потока
52
     *
53
     * @param string $alias Алиаса потока
54
     * @param int $page Номер страницы
55
     * @return array
56
     * @throws IncorrectUsageException
57
     */
58 1
    public function getFeedAll($alias, $page = 1)
59
    {
60 1
        $this->checkAliasName($alias);
61 1
        $this->checkPageNumber($page);
62
63 1
        return $this->adapter->get(sprintf('/flows/%s/all?page=%d', $alias, $page));
64
    }
65
66
    /**
67
     * Возвращает "Лучшие" посты из потока
68
     *
69
     * @param string $alias Алиаса потока
70
     * @param int $page Номер страницы
71
     * @return array
72
     * @throws IncorrectUsageException
73
     */
74 1
    public function getFeedBest($alias, $page = 1)
75
    {
76 1
        $this->checkAliasName($alias);
77 1
        $this->checkPageNumber($page);
78
79 1
        return $this->adapter->get(sprintf('/flows/%s/best?page=%d', $alias, $page));
80
    }
81
82
    /**
83
     * Возвращает список хабов потока
84
     *
85
     * @param string $alias Алиаса потока
86
     * @param int $page Номер страницы
87
     * @return array
88
     * @throws IncorrectUsageException
89
     */
90 1
    public function getHubList($alias, $page = 1)
91
    {
92 1
        $this->checkAliasName($alias);
93 1
        $this->checkPageNumber($page);
94
95 1
        return $this->adapter->get(sprintf('/flows/%s/hubs?page=%d', $alias, $page));
96
    }
97
}
98