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

Client   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 4
dl 0
loc 49
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 9 1
A tone() 0 4 1
A toneChat() 0 4 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
    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