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

ScriptFields::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
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 6
rs 10
1
<?php
2
3
4
namespace Manticoresearch\Query;
5
6
7
use Manticoresearch\Query;
8
9
class ScriptFields extends Query
10
{
11
    private $obj;
12
13
    public function __construct()
14
    {
15
        $this->obj = new \stdClass();
16
    }
17
18
    public function add($field, $args = [])
19
    {
20
21
        $this->obj->$field = [
22
            'script' => [
23
                'inline' => $args
24
            ]
25
26
        ];
27
    }
28
29
    public function toArray()
30
    {
31
32
        return parent::_toArray(json_decode(json_encode($this->obj)));
33
    }
34
35
36
}