Connection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 18
ccs 4
cts 5
cp 0.8
rs 10
wmc 3

1 Method

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