Completed
Push — 2.0 ( d7d09e...57ce97 )
by Peter
06:52 queued 12s
created

MinSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 38
loc 38
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 4 4 1
A it_is_a_count_distinct() 4 4 1
A it_is_a_operand() 4 4 1
A it_is_transformable() 4 4 1
A it_is_transformable_distinct() 6 6 1
A it_is_executable() 6 6 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
declare(strict_types=1);
3
4
/**
5
 * This file is part of the Happyr Doctrine Specification package.
6
 *
7
 * (c) Tobias Nyholm <[email protected]>
8
 *     Kacper Gunia <[email protected]>
9
 *     Peter Gribanov <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace tests\Happyr\DoctrineSpecification\Operand\PlatformFunction;
16
17
use Doctrine\ORM\QueryBuilder;
18
use Happyr\DoctrineSpecification\Exception\OperandNotExecuteException;
19
use Happyr\DoctrineSpecification\Operand\Operand;
20
use Happyr\DoctrineSpecification\Operand\PlatformFunction\Min;
21
use PhpSpec\ObjectBehavior;
22
23
/**
24
 * @mixin Min
25
 */
26 View Code Duplication
final class MinSpec extends ObjectBehavior
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...
27
{
28
    private $field = 'foo';
29
30
    public function let(): void
31
    {
32
        $this->beConstructedWith($this->field);
33
    }
34
35
    public function it_is_a_count_distinct(): void
36
    {
37
        $this->shouldBeAnInstanceOf(Min::class);
38
    }
39
40
    public function it_is_a_operand(): void
41
    {
42
        $this->shouldBeAnInstanceOf(Operand::class);
43
    }
44
45
    public function it_is_transformable(QueryBuilder $qb): void
46
    {
47
        $this->transform($qb, 'a')->shouldReturn('MIN(a.foo)');
48
    }
49
50
    public function it_is_transformable_distinct(QueryBuilder $qb): void
51
    {
52
        $this->beConstructedWith($this->field, true);
53
54
        $this->transform($qb, 'a')->shouldReturn('MIN(DISTINCT a.foo)');
55
    }
56
57
    public function it_is_executable(): void
58
    {
59
        $candidate = null; // not used
60
61
        $this->shouldThrow(OperandNotExecuteException::class)->duringExecute($candidate);
62
    }
63
}
64