AbstractAdapterTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 45.45 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 25
loc 55
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testAdapter() 0 15 1
A testAdd() 11 14 1
A testRemove() 14 17 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
 * This file is part of the bee4/events package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @copyright Bee4 2014
8
 * @author  Stephane HULARD <[email protected]>
9
 */
10
11
namespace Bee4\Events\Test\Units\Adapters;
12
13
/**
14
 * Check behaviour of an adapter
15
 */
16
abstract class AbstractAdapterTest extends \atoum
17
{
18
19
    protected $adapter;
20
21
    public function testAdapter()
22
    {
23
        $this
24
            ->given(
25
                $handler = function () {
26
                    echo "Youpi!";
27
                },
28
                $event = new \mock\Bee4\Events\EventInterface
29
            )
30
            ->when($this->adapter->add('name', $handler))
31
            ->output(function () use ($event) {
32
                $this->adapter->dispatch('name', $event);
33
            })
34
                ->isEqualTo("Youpi!");
35
    }
36
37 View Code Duplication
    public function testAdd()
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...
38
    {
39
        $this
40
            ->given($handler = function () {
41
                echo "Youpi!";
42
            })
43
            ->then
44
                ->array($this->adapter->get('name'))
45
                    ->hasSize(0)
46
            ->when($this->adapter->add('name', $handler))
47
            ->then
48
                ->array($this->adapter->get('name'))
49
                    ->hasSize(1);
50
    }
51
52
53 View Code Duplication
    public function testRemove()
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...
54
    {
55
        $this
56
            ->given(
57
                $handler = function () {
58
                    echo "Youpi!";
59
                },
60
                $this->adapter->add('name', $handler)
61
            )
62
            ->then
63
                ->array($this->adapter->get('name'))
64
                    ->hasSize(1)
65
            ->when($this->adapter->remove('name', $handler))
66
            ->then
67
                ->array($this->adapter->get('name'))
68
                    ->hasSize(0);
69
    }
70
}
71