AuthenticatorFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 21
ccs 7
cts 7
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 10 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Laravel GitLab.
7
 *
8
 * (c) Graham Campbell <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace GrahamCampbell\GitLab\Authenticators;
15
16
use Gitlab\Client;
17
use InvalidArgumentException;
18
19
/**
20
 * This is the authenticator factory class.
21
 *
22
 * @author Graham Campbell <[email protected]>
23
 */
24
class AuthenticatorFactory
25
{
26
    /**
27
     * Make a new authenticator instance.
28
     *
29
     * @param string $method
30
     *
31
     * @throws \InvalidArgumentException
32
     *
33
     * @return \GrahamCampbell\GitLab\Authenticators\AuthenticatorInterface
34
     */
35 132
    public function make(string $method)
36
    {
37 110
        switch ($method) {
38 132
            case 'oauth':
39 12
                return new GitLabAuthenticator(Client::AUTH_OAUTH_TOKEN);
40 120
            case 'token':
41 96
                return new GitLabAuthenticator(Client::AUTH_HTTP_TOKEN);
42
        }
43
44 24
        throw new InvalidArgumentException("Unsupported authentication method [$method].");
45
    }
46
}
47