Completed
Branch develop (3cde25)
by Adam
14:50
created

Client::tone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
    public static function create($username, $password)
28
    {
29
        $httpClient = (new Builder())
30
            ->withEndpoint(static::BASE_URI)
31
            ->withCredentials($username, $password)
32
            ->createConfiguredClient();
33
34
        return new self($httpClient);
35
    }
36
37
    /**
38
     * Create tone api request
39
     *
40
     * @return \IBM\Watson\ToneAnalyzer\Api\Tone
41
     */
42
    public function tone()
43
    {
44
        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
    public function toneChat()
53
    {
54
        return new Api\ToneChat($this->httpClient, $this->hydrator, $this->requestBuilder);
55
    }
56
}
57