Completed
Push — 1.0 ( 75b22b...f155d9 )
by Peter
15:56 queued 05:56
created

SelectSpec   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 44
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 44
loc 44
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 4 4 1
A it_is_a_select() 4 4 1
A it_is_a_specification() 4 4 1
A it_select_single_filed() 5 5 1
A it_select_several_fields() 6 6 1
A it_select_several_fields_as_array() 6 6 1
A it_select_operand() 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
3
namespace tests\Happyr\DoctrineSpecification\Query;
4
5
use Doctrine\ORM\QueryBuilder;
6
use Happyr\DoctrineSpecification\Operand\Field;
7
use Happyr\DoctrineSpecification\Query\Select;
8
use PhpSpec\ObjectBehavior;
9
10
/**
11
 * @mixin Select
12
 */
13 View Code Duplication
class SelectSpec 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...
14
{
15
    public function let()
16
    {
17
        $this->beConstructedWith('foo');
18
    }
19
20
    public function it_is_a_select()
21
    {
22
        $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Query\Select');
23
    }
24
25
    public function it_is_a_specification()
26
    {
27
        $this->shouldHaveType('Happyr\DoctrineSpecification\Query\QueryModifier');
28
    }
29
30
    public function it_select_single_filed(QueryBuilder $qb)
31
    {
32
        $qb->select(['a.foo'])->shouldBeCalled();
33
        $this->modify($qb, 'a');
34
    }
35
36
    public function it_select_several_fields(QueryBuilder $qb)
37
    {
38
        $this->beConstructedWith('foo', 'bar');
39
        $qb->select(['b.foo', 'b.bar'])->shouldBeCalled();
40
        $this->modify($qb, 'b');
41
    }
42
43
    public function it_select_several_fields_as_array(QueryBuilder $qb)
44
    {
45
        $this->beConstructedWith(['foo', 'bar']);
46
        $qb->select(['b.foo', 'b.bar'])->shouldBeCalled();
47
        $this->modify($qb, 'b');
48
    }
49
50
    public function it_select_operand(QueryBuilder $qb)
51
    {
52
        $this->beConstructedWith('foo', new Field('bar'));
53
        $qb->select(['b.foo', 'b.bar'])->shouldBeCalled();
54
        $this->modify($qb, 'b');
55
    }
56
}
57