Passed
Branch master (8cb5b2)
by Christopher
04:33 queued 12s
created

Compound   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 74
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A disMax() 0 12 3
A functionScore() 0 10 1
A constantScore() 0 7 1
A boosting() 0 7 1
1
<?php
0 ignored issues
show
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
2
namespace Triadev\Leopard\Business\Dsl\Query;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
use ONGR\ElasticsearchDSL\BuilderInterface;
5
use ONGR\ElasticsearchDSL\Query\Compound\BoostingQuery;
6
use ONGR\ElasticsearchDSL\Query\Compound\ConstantScoreQuery;
7
use ONGR\ElasticsearchDSL\Query\Compound\DisMaxQuery;
8
use Triadev\Leopard\Business\Dsl\FunctionScore;
9
use Triadev\Leopard\Business\Dsl\Search;
10
use Triadev\Leopard\Business\Dsl\AbstractQuery;
11
12
class Compound extends AbstractQuery
0 ignored issues
show
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
13
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class Compound
Loading history...
14
    /**
15
     * Function score
16
     *
17
     * @param \Closure $search
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
18
     * @param \Closure $functionScore
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
19
     * @param array $params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
20
     * @return Compound
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
21
     */
22 6
    public function functionScore(\Closure $search, \Closure $functionScore, array $params = []) : Compound
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$params" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$params"; expected 0 but found 1
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 107 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
23
    {
24 6
        $searchBuilder = app()->make(Search::class);
25 6
        $search($searchBuilder);
26
        
27 6
        $functionScoreBuilder = new FunctionScore($searchBuilder->getQuery(), $params);
28 6
        $functionScore($functionScoreBuilder);
29
        
30 6
        $this->append($functionScoreBuilder->getQuery());
31 6
        return $this;
32
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end functionScore()
Loading history...
33
    
34
    /**
35
     * Constant score
36
     *
37
     * @param \Closure $search
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
38
     * @param array $params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
39
     * @return Compound
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
40
     */
41 1
    public function constantScore(\Closure $search, array $params = []) : Compound
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$params" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$params"; expected 0 but found 1
Loading history...
42
    {
43 1
        $searchBuilder = app()->make(Search::class);
44 1
        $search($searchBuilder);
45
        
46 1
        $this->append(new ConstantScoreQuery($searchBuilder->getQuery(), $params));
47 1
        return $this;
48
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end constantScore()
Loading history...
49
    
50
    /**
51
     * Boosting
52
     *
53
     * @param BuilderInterface $positive
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
54
     * @param BuilderInterface $negative
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
55
     * @param float $negativeBoost
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 12 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
56
     * @return Compound
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
57
     */
58 2
    public function boosting(
59
        BuilderInterface $positive,
60
        BuilderInterface $negative,
61
        float $negativeBoost
62
    ) : Compound {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
63 2
        $this->append(new BoostingQuery($positive, $negative, $negativeBoost));
64 2
        return $this;
65
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end boosting()
Loading history...
66
    
67
    /**
68
     * Dis max
69
     *
70
     * @param BuilderInterface[] $queries
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
71
     * @param array $params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 14 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
72
     * @return Compound
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
73
     */
74 1
    public function disMax(array $queries, array $params = []) : Compound
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$params" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$params"; expected 0 but found 1
Loading history...
75
    {
76 1
        $disMaxQuery = new DisMaxQuery($params);
77
        
78 1
        foreach ($queries as $query) {
79 1
            if ($query instanceof BuilderInterface) {
80 1
                $disMaxQuery->addQuery($query);
81
            }
82
        }
83
        
84 1
        $this->append($disMaxQuery);
85 1
        return $this;
86
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end disMax()
Loading history...
87
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
88