Keywords   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setBody() 0 14 4
A getIndex() 0 3 1
A setIndex() 0 3 1
1
<?php
2
3
4
namespace Manticoresearch\Endpoints;
5
6
use Manticoresearch\Exceptions\RuntimeException;
7
use Manticoresearch\Utils;
8
9
class Keywords extends EmulateBySql
10
{
11
    use Utils;
12
    protected $index;
13
14
    public function setBody($params = null)
15
    {
16
        if (isset($this->index)) {
17
            $binds =[];
18
            $binds[] = "'" . static::escape($params['query']) . "'";
19
            $binds[] = "'" . $this->index . "'";
20
            if (count($params['options']) > 0) {
21
                foreach ($params['options'] as $name => $value) {
22
                    $binds[] = "$value AS $name";
23
                }
24
            }
25
            return parent::setBody(['query' => "CALL KEYWORDS(" . implode(",", $binds) . ")"]);
26
        }
27
        throw new RuntimeException('Index name is missing.');
28
    }
29
    public function getIndex()
30
    {
31
        return $this->index;
32
    }
33
34
    /**
35
     * @param mixed $index
36
     */
37
    public function setIndex($index)
38
    {
39
        $this->index = $index;
40
    }
41
}
42