BasicAuthClient::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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