Completed
Push — 2.0 ( 33bb83...14462a )
by Peter
07:18 queued 16s
created

LeftJoinSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 32
loc 32
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 4 4 1
A it_joins_with_default_dql_alias() 6 6 1
A it_joins_in_context() 12 12 1
A it_is_a_query_modifier() 4 4 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\Query;
16
17
use Doctrine\ORM\QueryBuilder;
18
use Happyr\DoctrineSpecification\Query\LeftJoin;
19
use Happyr\DoctrineSpecification\Query\QueryModifier;
20
use PhpSpec\ObjectBehavior;
21
22
/**
23
 * @mixin LeftJoin
24
 */
25 View Code Duplication
final class LeftJoinSpec 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...
26
{
27
    public function let(): void
28
    {
29
        $this->beConstructedWith('user', 'authUser', null);
30
    }
31
32
    public function it_is_a_query_modifier(): void
33
    {
34
        $this->shouldHaveType(QueryModifier::class);
35
    }
36
37
    public function it_joins_with_default_dql_alias(QueryBuilder $qb): void
38
    {
39
        $qb->leftJoin('a.user', 'authUser')->shouldBeCalled();
40
41
        $this->modify($qb, 'a');
42
    }
43
44
    public function it_joins_in_context(QueryBuilder $qb): void
45
    {
46
        $this->beConstructedWith('user', 'authUser', 'x');
47
48
        $qb->leftJoin('x.user', 'authUser')->shouldBeCalled();
49
50
        $qb->getDQLPart('join')->willReturn([]);
51
        $qb->getAllAliases()->willReturn([]);
52
        $qb->join('root.x', 'x')->willReturn($qb);
53
54
        $this->modify($qb, 'root');
55
    }
56
}
57