EventDispatcherAdapter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 23
ccs 8
cts 10
cp 0.8
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A dispatch() 0 3 1
A __construct() 0 6 2
A addListener() 0 3 1
1
<?php declare(strict_types=1);
0 ignored issues
show
Coding Style introduced by
This file is missing a doc comment.
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "EventDispatcherAdapter.php" doesn't match the expected filename "eventdispatcheradapter.php"
Loading history...
2
3
namespace Star\Component\State\Port\Symfony;
4
5
use Star\Component\State\Event\StateEvent;
6
use Star\Component\State\EventRegistry;
7
use Symfony\Component\EventDispatcher\EventDispatcher;
8
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
9
10
final class EventDispatcherAdapter implements EventRegistry
0 ignored issues
show
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
11
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class EventDispatcherAdapter
Loading history...
12
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
13
     * @var EventDispatcherInterface
14
     */
15
    private $dispatcher;
0 ignored issues
show
Coding Style introduced by
Private member variable "dispatcher" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style introduced by
Private member variable "dispatcher" must be prefixed with an underscore
Loading history...
16
17 36
    public function __construct(EventDispatcherInterface $dispatcher = null)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
18
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
19 36
        if (! $dispatcher) {
20 36
            $dispatcher = new EventDispatcher();
21
        }
22 36
        $this->dispatcher = $dispatcher;
23 36
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end __construct()
Loading history...
24
25 23
    public function dispatch(string $name, StateEvent $event): void
0 ignored issues
show
Unused Code introduced by
The method parameter $name is never used
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
26
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
27 23
        $this->dispatcher->dispatch($event);
28 23
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end dispatch()
Loading history...
29
30
    public function addListener(string $event, callable $listener): void
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
31
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
32
        $this->dispatcher->addListener($event, $listener);
33
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end addListener()
Loading history...
34
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
35