Completed
Push — master ( ec539d...346131 )
by Adrian
02:33 queued 11s
created

Query   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 4 1
A _toArray() 0 18 5
A add() 0 2 1
1
<?php
2
3
4
namespace Manticoresearch;
5
6
7
class Query implements Arrayable
8
{
9
    protected $_params;
10
11
    public function add($k,$v) {
12
        $this->_params[$k] = $v;
13
    }
14
    public function toArray()
15
    {
16
17
       return  $this->_toArray($this->_params);
18
    }
19
20
    protected function _toArray($params)
21
    {
22
        $return = [];
23
        foreach ($params as $k => $v) {
24
            if ($v instanceof Arrayable) {
25
                $return[$k] = $v->toArray();
26
            } elseif (is_array($v)) {
27
                $return[$k] = $this->_toArray($v);
28
            } else {
29
                if($v!==null) {
30
                    $return[$k] = $v;
31
                }else {
32
                    return null;
33
                }
34
35
            }
36
        }
37
        return $return;
38
    }
39
}
40