Completed
Push — master ( a95c92...e40b6a )
by Beñat
04:36
created

UserAPI::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * Copyright (c) 2015 Beñat Espiña <[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 BenatEspina\StackExchangeApiClient\Method;
13
14
use BenatEspina\StackExchangeApiClient\Client;
15
16
/**
17
 * Class UserAPI.
18
 *
19
 * @author Beñat Espiña <[email protected]>
20
 */
21
class UserAPI
22
{
23
    /**
24
     * Client instance.
25
     *
26
     * @var \BenatEspina\StackExchangeApiClient\Client
27
     */
28
    protected $client;
29
30
    /**
31
     * The prefix of users API requests.
32
     *
33
     * @var string
34
     */
35
    protected $prefix = '/users';
36
37
    /**
38
     * Constructor.
39
     *
40
     * @param \BenatEspina\StackExchangeApiClient\Client $client that will be used to connect the server
41
     */
42
    public function __construct(Client $client)
43
    {
44
        $this->client = $client;
45
    }
46
47
    /**
48
     * Get all users, in alphabetical order.
49
     *
50
     * More info: https://api.stackexchange.com/docs/users
51
     *
52
     * @param string[] $params QueryString parameter(s), by default, the basic to work:
53
     *                         array('site' => 'stackoverflow', 'sort' => 'name', 'order' => 'desc')
54
     *
55
     * @return array<BenatEspina\StackExchangeApiClient\Model\Interfaces\UserInterface>
56
     */
57
    public function getByIds($ids,
58
                             $params = ['site' => 'stackoverflow', 'sort' => 'name', 'order' => 'desc'])
59
    {
60
        return $this->client->get($this->prefix.'/'.implode(';', $ids), $params)['items'];
61
    }
62
}
63