Completed
Push — master ( 2a1eef...f81184 )
by Dmitry
02:53
created

Connection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 21
ccs 4
cts 5
cp 0.8
rs 10
c 2
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getResponseError() 0 10 3
1
<?php
2
/**
3
 * Tools to use API as ActiveRecord for Yii2
4
 *
5
 * @link      https://github.com/hiqdev/yii2-hiart
6
 * @package   yii2-hiart
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\hiart\rest;
12
13
use hiqdev\hiart\ResponseErrorException;
14
use hiqdev\hiart\ResponseInterface;
15
16
class Connection extends \hiqdev\hiart\AbstractConnection
17
{
18
    public $queryBuilderClass = QueryBuilder::class;
19
20
    /**
21
     * Method checks whether the response is an error
22
     *
23
     * @param ResponseInterface $response
24
     * @return false|string the error text or boolean `false`, when the response is not an error
25 2
     */
26
    public function getResponseError(ResponseInterface $response)
27 2
    {
28 2
        $code = $response->getStatusCode();
29 2
        if ($code >= 200 && $code < 300) {
30
            return false;
31
        }
32
33
        return $response->getReasonPhrase();
34
35
    }
36
}
37