ScoreMode   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A scoreMode() 0 15 2
1
<?php
2
/*
3
 * This file is part of PhpStorm.
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\Traits;
14
15
use PHPinnacle\Elastics\Exception;
16
17
trait ScoreMode
18
{
19
    /**
20
     * @var string
21
     */
22
    private $scoreMode;
23
24
    /**
25
     * @param string $mode
26
     *
27
     * @return self
28
     */
29
    public function scoreMode(string $mode): self
30
    {
31
        if (!\in_array($mode, [
32
            \ELASTICS_SCORE_MODE_AVG,
33
            \ELASTICS_SCORE_MODE_SUM,
34
            \ELASTICS_SCORE_MODE_MIN,
35
            \ELASTICS_SCORE_MODE_MAX,
36
            \ELASTICS_SCORE_MODE_NONE,
37
        ], true)) {
38
            throw new Exception\InvalidScoreMode($mode);
39
        }
40
41
        $this->scoreMode = $mode;
42
43
        return $this;
44
    }
45
}
46