BasicAuthClient   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 6
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace IBM\Watson\Common;
6
7
use IBM\Watson\Common\HttpClient\Builder;
8
use IBM\Watson\Common\Util\DiscoveryTrait;
9
10
/**
11
 * Service client which uses username and password to authenticate with the API.
12
 */
13
class BasicAuthClient extends AbstractClient implements BasicAuthClientInterface
14
{
15
    use DiscoveryTrait;
16
17
    /**
18
     * Create configured client using username and password.
19
     *
20
     * @param string $username API username.
21
     * @param string $password API password.
22
     *
23
     * @return \IBM\Watson\Common\BasicAuthClient
24
     */
25
    public static function create(string $username, string $password): BasicAuthClientInterface
26
    {
27
        $httpClient = (new Builder())
28
            ->withCredentials($username, $password)
29
            ->createConfiguredClient();
30
31
        return new self($httpClient);
32
    }
33
}
34