CompanyResource::getList()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Habrahabr\Api\Resources;
4
5
use Habrahabr\Api\Exception\IncorrectUsageException;
6
7
/**
8
 * Class CompanyResource
9
 *
10
 * Ресурс работы с компаниями
11
 *
12
 * @package Habrahabr\Api\Resources
13
 * @version 0.1.5
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 CompanyResource extends AbstractResource implements ResourceInterface
23
{
24
    /**
25
     * Возвращает посты компании по алиасу компании
26
     *
27
     * @param string $alias Алиасу компании на сайте
28
     * @param int $page Номер страницы
29
     * @return array
30
     * @throws IncorrectUsageException
31
     */
32 1
    public function getCompanyPosts($alias, $page = 1)
33
    {
34 1
        $this->checkAliasName($alias);
35 1
        $this->checkPageNumber($page);
36
37 1
        return $this->adapter->get(sprintf('/company/%s?page=%d', $alias, $page));
38
    }
39
40
    /**
41
     * Возвращает профиль компании по алиасу компании
42
     *
43
     * @param string $alias Алиасу компании на сайте
44
     * @return array
45
     * @throws IncorrectUsageException
46
     */
47 3
    public function getCompanyInfo($alias)
48
    {
49 3
        $this->checkAliasName($alias);
50
        
51 1
        return $this->adapter->get(sprintf('/company/%s/info', $alias));
52
    }
53
54
    /**
55
     * Возвращает список компаний
56
     *
57
     * @param int $page Номер страницы
58
     * @return array
59
     * @throws IncorrectUsageException
60
     */
61 2
    public function getList($page = 1)
62
    {
63 2
        $this->checkPageNumber($page);
64
65 1
        return $this->adapter->get(sprintf('/companies?page=%d', $page));
66
    }
67
}
68