Queued   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __call() 0 9 2
A getSubscribedEvents() 0 4 1
1
<?php
2
3
namespace Knp\RadBundle\DomainEvent\Dispatcher;
4
5
use Doctrine\Common\EventSubscriber;
6
7
class Queued implements EventSubscriber
8
{
9
    private $queuedEventNames;
10
    private $events = array();
0 ignored issues
show
Unused Code introduced by
The property $events is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
11
12
    public function __construct(array $queuedEventNames = array())
13
    {
14
        $this->queuedEventNames = $queuedEventNames;
15
    }
16
17
    public function __call($method, array $arguments)
18
    {
19
        if (!in_array(substr($method, 2), $this->queuedEventNames)) {
20
            throw new \BadMethodCallException;
21
        }
22
23
        // TODO, obviously use a real queue message producer
24
        file_put_contents(tempnam(sys_get_temp_dir(), 'queue'), serialize($event));
0 ignored issues
show
Bug introduced by
The variable $event does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
25
    }
26
27
    public function getSubscribedEvents()
28
    {
29
        return $this->delayedDomainEvents;
0 ignored issues
show
Bug introduced by
The property delayedDomainEvents does not seem to exist. Did you mean events?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
30
    }
31
}
32