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

ScriptFields   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

3 Methods

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