Completed
Push — v2 ( f8a429...e6c7b3 )
by Beñat
03:14
created

StackExchange::userApi()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * Copyright (c) 2014-2016 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;
13
14
use BenatEspina\StackExchangeApiClient\Api\AccessTokenApi;
15
use BenatEspina\StackExchangeApiClient\Api\AnswerApi;
16
use BenatEspina\StackExchangeApiClient\Api\UserApi;
17
use BenatEspina\StackExchangeApiClient\Authentication\Authentication;
18
19
/**
20
 * The StackExchange library entry point.
21
 *
22
 * You can instantiate the concrete API class, for example the AnswerApi but
23
 * if you plan to use the different api classes across your project, you could
24
 * use this facade that offers methods to access to any apis of the library.
25
 *
26
 * @author Beñat Espiña <[email protected]>
27
 */
28
final class StackExchange
29
{
30
    /**
31
     * The authentication instance.
32
     *
33
     * @var Authentication|null
34
     */
35
    private $authentication;
36
37
    /**
38
     * Constructor.
39
     *
40
     * @param Authentication|null $anAuthentication The authentication, it can be null
41
     */
42
    public function __construct(Authentication $anAuthentication = null)
43
    {
44
        $this->authentication = $anAuthentication;
45
    }
46
47
    /**
48
     * Gets the api related with access tokens.
49
     *
50
     * @return AccessTokenApi
51
     */
52
    public function accessTokenApi()
53
    {
54
        return new AccessTokenApi($this->authentication);
0 ignored issues
show
Unused Code introduced by
The call to AccessTokenApi::__construct() has too many arguments starting with $this->authentication.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
55
    }
56
57
    /**
58
     * Gets the api related with answers.
59
     *
60
     * @return AnswerApi
61
     */
62
    public function answerApi()
63
    {
64
        return new AnswerApi($this->authentication);
65
    }
66
67
    /**
68
     * Gets the api related with users.
69
     *
70
     * @return UserApi
71
     */
72
    public function userApi()
73
    {
74
        return new UserApi($this->authentication);
75
    }
76
}
77