Sql::getResponse()   A
last analyzed

Complexity

Conditions 5
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 8
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 14
rs 9.6111
1
<?php
2
3
namespace Manticoresearch\Response;
4
5
use Manticoresearch\Response;
6
7
class Sql extends Response
8
{
9
    public function getResponse()
10
    {
11
        $response = parent::getResponse();
12
        // workaround for the change in Manticore Search made in 4.2.1, after
13
        // which any query in mode=raw returns an array
14
        if (is_array($response)
15
        and count($response) === 1
16
        and isset($response[0]['total'], $response[0]['error'], $response[0]['warning'])) {
17
            foreach ($response[0] as $k => $v) {
18
                $response[$k] = $v;
19
            }
20
            unset($response[0]);
21
        }
22
        return $response;
23
    }
24
}
25