Completed
Push — 1.0 ( ea6409...9b1c59 )
by Peter
08:58
created

BitAndSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 37
loc 37
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 4 4 1
A it_is_a_bit_and() 4 4 1
A it_is_a_operand() 4 4 1
A it_is_transformable() 9 9 1
A it_is_transformable_add_fields() 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
namespace tests\Happyr\DoctrineSpecification\Operand;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\QueryBuilder;
7
use Happyr\DoctrineSpecification\Operand\BitAnd;
8
use Happyr\DoctrineSpecification\Operand\Field;
9
use PhpSpec\ObjectBehavior;
10
11
/**
12
 * @mixin BitAnd
13
 */
14 View Code Duplication
class BitAndSpec 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...
15
{
16
    private $field = 'foo';
17
18
    private $value = 'bar';
19
20
    public function let()
21
    {
22
        $this->beConstructedWith($this->field, $this->value);
23
    }
24
25
    public function it_is_a_bit_and()
26
    {
27
        $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Operand\BitAnd');
28
    }
29
30
    public function it_is_a_operand()
31
    {
32
        $this->shouldBeAnInstanceOf('Happyr\DoctrineSpecification\Operand\Operand');
33
    }
34
35
    public function it_is_transformable(QueryBuilder $qb, ArrayCollection $parameters)
36
    {
37
        $qb->getParameters()->willReturn($parameters);
38
        $parameters->count()->willReturn(10);
39
40
        $qb->setParameter('comparison_10', $this->value, null)->shouldBeCalled();
41
42
        $this->transform($qb, 'a')->shouldReturn('(a.foo & :comparison_10)');
43
    }
44
45
    public function it_is_transformable_add_fields(QueryBuilder $qb)
46
    {
47
        $this->beConstructedWith(new Field('foo'), new Field('bar'));
48
        $this->transform($qb, 'a')->shouldReturn('(a.foo & a.bar)');
49
    }
50
}
51