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

Client::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 9
Code Lines 7

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 8
nop 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A Client::classify() 0 4 1
1
<?php
2
3
namespace IBM\Watson\VisualRecognition;
4
5
use Http\Client\HttpClient;
6
use Http\Discovery\HttpClientDiscovery;
7
use IBM\Watson\Common\AbstractClient;
8
use IBM\Watson\Common\HttpClient\Builder;
9
use IBM\Watson\Common\Hydrator\HydratorInterface;
10
use IBM\Watson\Common\Hydrator\ModelHydrator;
11
use IBM\Watson\Common\RequestBuilder;
12
13
final class Client extends AbstractClient
14
{
15
    /**
16
     * @var string
17
     */
18
    const BASE_URI = 'https://gateway-a.watsonplatform.net/visual-recognition/api';
19
20
    /**
21
     * Create VisualRecognition client
22
     *
23
     * @param string $apiKey
24
     *
25
     * @return \IBM\Watson\VisualRecognition\Client
26
     *
27
     * @throws \RuntimeException
28
     * @throws \InvalidArgumentException
29
     * @throws \Http\Discovery\Exception\NotFoundException
30
     */
31
    public static function create($apiKey)
32
    {
33
        $httpClient = (new Builder())
34
            ->withEndpoint(static::BASE_URI)
35
            ->withApiKey($apiKey)
36
            ->withVersion(\date('Y-m-d'))
37
            ->createConfiguredClient();
38
39
        return new self($httpClient);
40
    }
41
42
    /**
43
     * Classify image
44
     *
45
     * @return \IBM\Watson\VisualRecognition\Api\Classify
46
     */
47
    public function classify()
48
    {
49
        return new Api\Classify($this->httpClient, $this->hydrator, $this->requestBuilder);
50
    }
51
}
52