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

ScriptFields   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 6 1
A __construct() 0 3 1
A toArray() 0 4 1
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
}