Completed
Push — develop ( 2c75a2...3f95e8 )
by Adam
08:12
created

BasicAuthClient::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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