Completed
Pull Request — develop (#19)
by Adam
02:07
created

Client::tone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace IBM\Watson\ToneAnalyzer;
4
5
use IBM\Watson\Common\AbstractClient;
6
use IBM\Watson\Common\HttpClient\Builder;
7
8
final class Client extends AbstractClient
9
{
10
    /**
11
     * Base tone analyzer uri
12
     */
13
    const BASE_URI = 'https://gateway.watsonplatform.net/tone-analyzer';
14
15
    /**
16
     * Create tone analyzer client with username and password
17
     *
18
     * @param string $username
19
     * @param string $password
20
     *
21
     * @return \IBM\Watson\ToneAnalyzer\Client
22
     *
23
     * @throws \Http\Discovery\Exception\NotFoundException
24
     * @throws \RuntimeException
25
     * @throws \InvalidArgumentException
26
     */
27 9
    public static function create($username, $password)
28
    {
29 9
        $httpClient = (new Builder())
30 9
            ->withEndpoint(static::BASE_URI)
31 9
            ->withCredentials($username, $password)
32 9
            ->createConfiguredClient();
33
34 9
        return new self($httpClient);
35
    }
36
37
    /**
38
     * Create tone api request
39
     *
40
     * @return \IBM\Watson\ToneAnalyzer\Api\Tone
41
     */
42 3
    public function tone()
43
    {
44 3
        return new Api\Tone($this->httpClient, $this->hydrator, $this->requestBuilder);
45
    }
46
47
    /**
48
     * Create tone chat api request
49
     *
50
     * @return \IBM\Watson\ToneAnalyzer\Api\ToneChat
51
     */
52 3
    public function toneChat()
53
    {
54 3
        return new Api\ToneChat($this->httpClient, $this->hydrator, $this->requestBuilder);
55
    }
56
}
57