Completed
Push — master ( 11f27c...4713a5 )
by Andreas
08:33
created

BucketAuto::convertExpression()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 4.5923

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 10
loc 10
ccs 4
cts 6
cp 0.6667
rs 9.2
cc 4
eloc 7
nc 3
nop 1
crap 4.5923
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace Doctrine\ODM\MongoDB\Aggregation\Stage;
21
22
class BucketAuto extends AbstractBucket
23
{
24
    /**
25
     * @var int
26
     */
27
    private $buckets;
28
29
    /**
30
     * @var string
31
     */
32
    private $granularity;
33
34
    /**
35
     * A positive 32-bit integer that specifies the number of buckets into which
36
     * input documents are grouped.
37
     *
38
     * @param int $buckets
39
     *
40
     * @return $this
41
     */
42 4
    public function buckets($buckets)
43
    {
44 4
        $this->buckets = $buckets;
45 4
        return $this;
46
    }
47
48
    /**
49
     * A string that specifies the preferred number series to use to ensure that
50
     * the calculated boundary edges end on preferred round numbers or their
51
     * powers of 10.
52
     *
53
     * @param string $granularity
54
     *
55
     * @return $this
56
     */
57 3
    public function granularity($granularity)
58
    {
59 3
        $this->granularity = $granularity;
60 3
        return $this;
61
    }
62
63
    /**
64
     * A document that specifies the fields to include in the output documents
65
     * in addition to the _id field. To specify the field to include, you must
66
     * use accumulator expressions.
67
     *
68
     * @return Bucket\BucketAutoOutput
69
     */
70 3
    public function output()
71
    {
72 3
        if (! $this->output) {
73 3
            $this->output = new Bucket\BucketAutoOutput($this->builder, $this);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\ODM\MongoD...($this->builder, $this) of type object<Doctrine\ODM\Mong...ucket\BucketAutoOutput> is incompatible with the declared type object<Doctrine\ODM\Mong...cket\BucketOutput>|null of property $output.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
74
        }
75
76 3
        return $this->output;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->output; of type Doctrine\ODM\MongoDB\Agg...age\Bucket\BucketOutput adds the type Doctrine\ODM\MongoDB\Agg...age\Bucket\BucketOutput to the return on line 76 which is incompatible with the return type documented by Doctrine\ODM\MongoDB\Agg...tage\BucketAuto::output of type Doctrine\ODM\MongoDB\Agg...Bucket\BucketAutoOutput.
Loading history...
77
    }
78
79 4
    protected function getExtraPipelineFields()
80
    {
81 4
        $fields = ['buckets' => $this->buckets];
82 4
        if ($this->granularity !== null) {
83 3
            $fields['granularity'] = $this->granularity;
84
        }
85
86 4
        return $fields;
87
    }
88
89 4
    protected function getStageName()
90
    {
91 4
        return '$bucketAuto';
92
    }
93
}
94