Completed
Push — master ( 26ecbc...8c0c5d )
by Maciej
14s
created

BucketAutoOutput   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 25%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 37
loc 37
ccs 3
cts 12
cp 0.25
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A groupBy() 5 5 1
A buckets() 5 5 1
A granularity() 5 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ODM\MongoDB\Aggregation\Stage\Bucket;
6
7
use Doctrine\ODM\MongoDB\Aggregation\Builder;
8
use Doctrine\ODM\MongoDB\Aggregation\Stage;
9
use function assert;
10
11
/**
12
 * Fluent interface for adding an output specification to a bucket stage.
13
 */
14 View Code Duplication
class BucketAutoOutput extends AbstractOutput
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16 3
    public function __construct(Builder $builder, Stage\BucketAuto $bucket)
17
    {
18 3
        parent::__construct($builder, $bucket);
19 3
    }
20
21
    /**
22
     * An expression to group documents by. To specify a field path, prefix the
23
     * field name with a dollar sign $ and enclose it in quotes.
24
     */
25
    public function groupBy($expression) : Stage\BucketAuto
26
    {
27
        assert($this->bucket instanceof Stage\BucketAuto);
28
        return $this->bucket->groupBy($expression);
29
    }
30
31
    /**
32
     * A positive 32-bit integer that specifies the number of buckets into which input documents are grouped.
33
     */
34
    public function buckets(int $buckets) : Stage\BucketAuto
35
    {
36
        assert($this->bucket instanceof Stage\BucketAuto);
37
        return $this->bucket->buckets($buckets);
38
    }
39
40
    /**
41
     * A string that specifies the preferred number series to use to ensure that
42
     * the calculated boundary edges end on preferred round numbers or their
43
     * powers of 10.
44
     */
45
    public function granularity(string $granularity) : Stage\BucketAuto
46
    {
47
        assert($this->bucket instanceof Stage\BucketAuto);
48
        return $this->bucket->granularity($granularity);
49
    }
50
}
51