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

Client   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 1
A 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