Passed
Push — master ( 53568f...6b64e2 )
by PHPinnacle
03:12
created

Script::compile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is part of PHPinnacle/Elastics.
4
 *
5
 * (c) PHPinnacle Team <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace PHPinnacle\Elastics\Query;
14
15
use PHPinnacle\Elastics\Query;
16
17
class Script implements Query
18
{
19
    /**
20
     * @var string
21
     */
22
    private $source;
23
24
    /**
25
     * @var array
26
     */
27
    private $params;
28
29
    /**
30
     * @var string
31
     */
32
    private $lang;
33
34
    /**
35
     * @param string $source
36
     * @param array  $params
37
     * @param string $lang
38
     */
39 2
    public function __construct(string $source, array $params = [], string $lang = \ELASTICS_LANG_PAINLESS)
40
    {
41 2
        $this->source = $source;
42 2
        $this->params = $params;
43 2
        $this->lang   = $lang;
44 2
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 1
    public function name(): string
50
    {
51 1
        return 'script';
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 1
    public function compile(): array
58
    {
59
        return [
60
            'script' => [
61 1
                'source' => $this->source,
62 1
                'params' => $this->params,
63 1
                'lang'   => $this->lang,
64
            ],
65
        ];
66
    }
67
}
68