GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#2)
by Sylvain
07:47 queued 03:21
created

DoctrineSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 55.74 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 0
cbo 5
dl 34
loc 61
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 3 1
A it_is_initializable() 0 4 1
A it_pops_events_of_a_post_persisted_entity() 17 17 1
A it_pops_events_of_a_post_loaded_entity() 17 17 1
A it_doesnt_dispatch_events_of_non_provider_entities() 0 13 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\Knp\Rad\DomainEvent\Dispatcher;
4
5
use PhpSpec\ObjectBehavior;
6
use Prophecy\Argument;
7
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
8
use Knp\Rad\DomainEvent\Provider;
9
use Doctrine\ORM\Event\LifecycleEventArgs;
10
use Doctrine\ORM\Event\PostFlushEventArgs;
11
use Knp\Rad\DomainEvent\Event;
12
13
class DoctrineSpec extends ObjectBehavior
14
{
15
    function let(EventDispatcherInterface $dispatcher) {
16
        $this->beConstructedWith($dispatcher);
17
    }
18
19
    function it_is_initializable()
20
    {
21
        $this->shouldHaveType('Knp\Rad\DomainEvent\Dispatcher\Doctrine');
22
    }
23
24 View Code Duplication
    function it_pops_events_of_a_post_persisted_entity(
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...
25
        LifecycleEventArgs $event,
26
        Provider $entity,
27
        PostFlushEventArgs $postFlushEvent,
28
        Event $raisedEvent,
29
        $dispatcher
30
    ) {
31
        $event->getEntity()->willReturn($entity);
32
        $entity->popEvents()->willReturn([$raisedEvent]);
33
34
        $raisedEvent->setSubject($entity)->shouldBeCalled();
35
        $raisedEvent->getName()->willReturn('FooEvent');
36
        $dispatcher->dispatch('FooEvent', $raisedEvent)->shouldBeCalled();
37
38
        $this->postPersist($event);
39
        $this->postFlush($postFlushEvent);
40
    }
41
42 View Code Duplication
    function it_pops_events_of_a_post_loaded_entity(
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...
43
        LifecycleEventArgs $event,
44
        Provider $entity,
45
        PostFlushEventArgs $postFlushEvent,
46
        Event $raisedEvent,
47
        $dispatcher
48
    ) {
49
        $event->getEntity()->willReturn($entity);
50
        $entity->popEvents()->willReturn([$raisedEvent]);
51
52
        $raisedEvent->setSubject($entity)->shouldBeCalled();
53
        $raisedEvent->getName()->willReturn('FooEvent');
54
        $dispatcher->dispatch('FooEvent', $raisedEvent)->shouldBeCalled();
55
56
        $this->postLoad($event);
57
        $this->postFlush($postFlushEvent);
58
    }
59
60
    function it_doesnt_dispatch_events_of_non_provider_entities(
61
        LifecycleEventArgs $event,
62
        \StdClass $entity,
63
        PostFlushEventArgs $postFlushEvent,
64
        Event $raisedEvent,
65
        $dispatcher
66
    ) {
67
        $event->getEntity()->willReturn($entity);
68
        $dispatcher->dispatch(Argument::any(), $raisedEvent)->shouldNotBeCalled();
69
70
        $this->postPersist($event);
71
        $this->postFlush($postFlushEvent);
72
    }
73
}
74