Passed
Pull Request — develop (#23)
by Adam
01:31
created

Service   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 31
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 9 1
A tone() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace IBM\Watson\ToneAnalyzer;
6
7
use Http\Message\Authentication;
8
use IBM\Watson\Common\HttpClient\Builder;
9
use IBM\Watson\Common\WatsonService;
10
use IBM\Watson\Common\WatsonServiceInterface;
11
use IBM\Watson\ToneAnalyzer\Api\Tone;
12
13
/**
14
 * ToneAnalyzer service interfaces the ToneAnalyzer API.
15
 */
16
class Service extends WatsonService
17
{
18
    const API_HOSTNAME = 'https://gateway.watsonplatform.net/tone-analyzer/api';
19
    const API_PATH = 'tone-analyzer/api/v3';
20
21
    /**
22
     * Create configured service.
23
     *
24
     * @param \Http\Message\Authentication $authentication Authentication method.
25
     *
26 3
     * @return \IBM\Watson\Common\WatsonServiceInterface
27
     */
28 3
    public static function create(Authentication $authentication): WatsonServiceInterface
29
    {
30
        $httpClient = (new Builder())
31
            ->withHostname(static::API_HOSTNAME)
32
            ->withPath(static::API_PATH)
33
            ->withAuthentication($authentication)
34
            ->createConfiguredClient();
35
36 3
        return new self($httpClient);
37
    }
38 3
39
    /**
40
     * Use Tone endpoint.
41
     *
42
     * @return \IBM\Watson\ToneAnalyzer\Api\Tone
43
     */
44
    public function tone(): Tone
45
    {
46
        return new Api\Tone($this->httpClient, $this->hydrator, $this->requestBuilder);
0 ignored issues
show
Bug introduced by
It seems like $this->httpClient can also be of type null; however, parameter $httpClient of IBM\Watson\ToneAnalyzer\Api\Tone::__construct() does only seem to accept Http\Client\HttpClient, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

46
        return new Api\Tone(/** @scrutinizer ignore-type */ $this->httpClient, $this->hydrator, $this->requestBuilder);
Loading history...
47 3
    }
48
}
49