1 | <?php |
||||
2 | /** |
||||
3 | * @category Library |
||||
4 | * @license MIT http://opensource.org/licenses/MIT |
||||
5 | * @link https://github.com/emlynwest/changelog |
||||
6 | */ |
||||
7 | |||||
8 | namespace ChangeLog\IO; |
||||
9 | |||||
10 | use ChangeLog\AbstractIO; |
||||
11 | use InvalidArgumentException; |
||||
12 | use Milo\Github\Api; |
||||
13 | use Milo\Github\OAuth\Token; |
||||
14 | |||||
15 | abstract class AbstractGitHubIO extends AbstractIO |
||||
16 | { |
||||
17 | |||||
18 | /** |
||||
19 | * @var Api |
||||
20 | */ |
||||
21 | protected $api; |
||||
22 | |||||
23 | /** |
||||
24 | * Gets an active connection to the GitHub api. |
||||
25 | * |
||||
26 | * @return Api |
||||
27 | */ |
||||
28 | 4 | protected function getApi() |
|||
29 | { |
||||
30 | 4 | if ($this->api === null) |
|||
31 | { |
||||
32 | 1 | $this->createApiInstance(); |
|||
33 | } |
||||
34 | |||||
35 | 3 | return $this->api; |
|||
36 | } |
||||
37 | |||||
38 | /** |
||||
39 | * Creates a new instance of the API library to use later. |
||||
40 | * |
||||
41 | * @throws InvalidArgumentException |
||||
42 | */ |
||||
43 | 1 | protected function createApiInstance() |
|||
44 | { |
||||
45 | 1 | $configToken = $this->getConfig('token'); |
|||
46 | |||||
47 | 1 | if ($configToken === null) |
|||
0 ignored issues
–
show
introduced
by
![]() |
|||||
48 | { |
||||
49 | 1 | throw new InvalidArgumentException('API token has not been set in the config.'); |
|||
50 | } |
||||
51 | |||||
52 | $token = new Token($configToken); |
||||
0 ignored issues
–
show
It seems like
$configToken can also be of type array ; however, parameter $value of Milo\Github\OAuth\Token::__construct() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
53 | $this->api = new Api(); |
||||
54 | $this->api->setToken($token); |
||||
55 | } |
||||
56 | |||||
57 | } |
||||
58 |