Cancelled
Branch master (8cb5b2)
by Christopher
04:16
created

Aggregation   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 72
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A append() 0 9 3
A pipeline() 0 7 1
A __construct() 0 3 1
A metric() 0 7 1
A bucketing() 0 7 1
1
<?php
0 ignored issues
show
Coding Style introduced by
This file is missing a doc comment.
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
2
namespace Triadev\Leopard\Business\Dsl;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation;
5
use Triadev\Leopard\Business\Dsl\Aggregation\Bucketing;
6
use Triadev\Leopard\Business\Dsl\Aggregation\Metric;
7
use Triadev\Leopard\Business\Dsl\Aggregation\Pipeline;
8
9
class Aggregation
0 ignored issues
show
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
10
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class Aggregation
Loading history...
11
    /** @var \ONGR\ElasticsearchDSL\Search */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
12
    private $search;
1 ignored issue
show
Coding Style introduced by
Private member variable "search" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style introduced by
Private member variable "search" must be prefixed with an underscore
Loading history...
13
    
14
    /**
15
     * Aggregation constructor.
16
     * @param \ONGR\ElasticsearchDSL\Search $search
0 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
17
     */
18 40
    public function __construct(\ONGR\ElasticsearchDSL\Search $search)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
19
    {
20 40
        $this->search = $search;
21 40
    }
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 __construct()
Loading history...
22
    
23
    /**
24
     * Bucketing
25
     *
26
     * @param \Closure $bucketing
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...
27
     * @return Aggregation
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
28
     */
29 16
    public function bucketing(\Closure $bucketing) : Aggregation
30
    {
31 16
        $bucketingBuilder = new Bucketing();
32 16
        $bucketing($bucketingBuilder);
33
        
34 16
        $this->append($bucketingBuilder->getAggregations());
35 16
        return $this;
36
    }
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 bucketing()
Loading history...
37
    
38
    /**
39
     * Metric
40
     *
41
     * @param \Closure $metric
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...
42
     * @return Aggregation
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
43
     */
44 12
    public function metric(\Closure $metric) : Aggregation
45
    {
46 12
        $metricBuilder = new Metric();
47 12
        $metric($metricBuilder);
48
        
49 12
        $this->append($metricBuilder->getAggregations());
50 12
        return $this;
51
    }
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 metric()
Loading history...
52
    
53
    /**
54
     * Pipeline
55
     *
56
     * @param \Closure $pipeline
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...
57
     * @return Aggregation
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
58
     */
59 12
    public function pipeline(\Closure $pipeline) : Aggregation
60
    {
61 12
        $pipelineBuilder = new Pipeline();
62 12
        $pipeline($pipelineBuilder);
63
        
64 12
        $this->append($pipelineBuilder->getAggregations());
65 12
        return $this;
66
    }
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 pipeline()
Loading history...
67
    
68
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
69
     * @param AbstractAggregation[] $aggs
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
70
     * @return Aggregation
71
     */
72 40
    private function append(array $aggs) : Aggregation
0 ignored issues
show
Coding Style introduced by
Private method name "Aggregation::append" must be prefixed with an underscore
Loading history...
73
    {
74 40
        foreach ($aggs as $agg) {
75 40
            if ($agg instanceof AbstractAggregation) {
76 40
                $this->search->addAggregation($agg);
77
            }
78
        }
79
        
80 40
        return $this;
81
    }
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 append()
Loading history...
82
}
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...
83