Passed
Push — master ( d0634e...13c37e )
by Yuichi
10:21 queued 22s
created

Client   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 55.56%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 8
c 3
b 1
f 0
dl 0
loc 29
ccs 5
cts 9
cp 0.5556
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A connectionTest() 0 5 2
A __construct() 0 8 2
1
<?php
2
3
namespace CybozuHttp;
4
5
use CybozuHttp\Exception\RedirectResponseException;
6
use GuzzleHttp\Client as GuzzleClient;
7
use CybozuHttp\Exception\NotExistRequiredException;
8
9
/**
10
 * @author ochi51<[email protected]>
11
 */
12
class Client extends GuzzleClient
13
{
14
15
    /**
16
     * Client constructor.
17
     * @param array $config
18
     * @throws NotExistRequiredException
19
     */
20 3
    public function __construct(array $config = [])
21
    {
22 3
        $cybozuConfig = new Config($config);
23 3
        if (!$cybozuConfig->hasRequired()) {
24 1
            throw new NotExistRequiredException('Parameters is invalid.');
25
        }
26
27 3
        parent::__construct($cybozuConfig->toGuzzleConfig());
28
    }
29
30
    /**
31
     * @param string $prefix
32
     * @throws RedirectResponseException
33
     * @throws \GuzzleHttp\Exception\GuzzleException
34
     * @deprecated Due to changes in kintone specifications, this function is not working.
35
     */
36
    public function connectionTest($prefix = '/'): void
37
    {
38
        $response = $this->request('GET', $prefix, ['allow_redirects' => false]);
39
        if ($response->getStatusCode() === 302) {
40
            throw new RedirectResponseException('', $response);
41
        }
42
    }
43
}
44