Completed
Branch develop (9f43d2)
by Filipe
05:14
created

ContainerBuilderSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 29.79 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A its_container_aware() 0 4 1
A it_creates_empty_containers() 0 5 1
A it_hydrates_a_container_with_an_array_of_definitions() 0 11 1
A it_hydrates_a_container_with_an_array_from_a_file() 7 7 1
A it_hydrates_a_container_with_all_arrays_form_the_files_within_a_directory() 7 7 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 spec\Slick\Di;
4
5
use Slick\Di\ContainerInterface;
6
use Slick\Di\ContainerAwareInterface;
7
use Slick\Di\ContainerBuilder;
8
use PhpSpec\ObjectBehavior;
9
use Prophecy\Argument;
10
11
class ContainerBuilderSpec extends ObjectBehavior
12
{
13
    function it_is_initializable()
14
    {
15
        $this->shouldHaveType(ContainerBuilder::class);
16
    }
17
18
    function its_container_aware()
19
    {
20
        $this->shouldBeAnInstanceOf(ContainerAwareInterface::class);
21
    }
22
23
    function it_creates_empty_containers()
24
    {
25
        $this->beConstructedWith();
26
        $this->getContainer()->shouldBeAnInstanceOf(ContainerInterface::class);
27
    }
28
29
    function it_hydrates_a_container_with_an_array_of_definitions(ContainerInterface $container)
30
    {
31
        $services = [
32
            'foo' => 'bar',
33
            'baz' => '@foo'
34
        ];
35
        $container->register(Argument::type('string'), Argument::any())->shouldBeCalledTimes(2);
36
        $this->beConstructedWith($services);
37
        $this->setContainer($container);
38
        $this->getContainer()->shouldBeAnInstanceOf(ContainerInterface::class);
39
    }
40
41 View Code Duplication
    function it_hydrates_a_container_with_an_array_from_a_file(ContainerInterface $container)
0 ignored issues
show
Duplication introduced by
This method 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...
42
    {
43
        $container->register(Argument::type('string'), Argument::any())->shouldBeCalledTimes(3);
44
        $this->beConstructedWith(__DIR__ .'/services/services1.php');
45
        $this->setContainer($container);
46
        $this->getContainer()->shouldBeAnInstanceOf(ContainerInterface::class);
47
    }
48
49 View Code Duplication
    function it_hydrates_a_container_with_all_arrays_form_the_files_within_a_directory(ContainerInterface $container)
0 ignored issues
show
Duplication introduced by
This method 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...
50
    {
51
        $container->register(Argument::type('string'), Argument::any())->shouldBeCalledTimes(6);
52
        $this->beConstructedWith(__DIR__ .'/services');
53
        $this->setContainer($container);
54
        $this->getContainer()->shouldBeAnInstanceOf(ContainerInterface::class);
55
    }
56
57
}
58