Passed
Push — 1.x ( 77e7f6...966118 )
by Adrian
02:40 queued 12s
created

ScriptFields::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
4
namespace Manticoresearch\Query;
5
6
use Manticoresearch\Query;
7
8
class ScriptFields extends Query
9
{
10
    private $obj;
11
12
    public function __construct()
13
    {
14
        $this->obj = new \stdClass();
15
    }
16
17
    public function add($field, $args = [])
18
    {
19
        $this->obj->$field = [
20
            'script' => [
21
                'inline' => $args
22
            ]
23
24
        ];
25
    }
26
27
    public function toArray()
28
    {
29
        return $this->_toArray(json_decode(json_encode($this->obj), true));
30
    }
31
}
32