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

Connection::checkResponse()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 4.125

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 4
cts 8
cp 0.5
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 2
nop 1
crap 4.125
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