Passed
Push — master ( d917f3...9bdfff )
by Jesse
02:48
created

BringerOfBadNews::handle()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 24
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 16
c 1
b 0
f 0
nc 16
nop 1
dl 0
loc 24
rs 9.4222
1
<?php declare(strict_types=1);
0 ignored issues
show
Coding Style introduced by
Class found in ".php" file; use ".inc" extension instead
Loading history...
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 "BringerOfBadNews.php" doesn't match the expected filename "bringerofbadnews.php"
Loading history...
introduced by
The PHP open tag must be followed by exactly one blank line
Loading history...
introduced by
Expected 1 space before "="; 0 found
Loading history...
introduced by
Expected 1 space after "="; 0 found
Loading history...
2
3
namespace Stratadox\CardGame\EventHandler;
4
5
use Stratadox\CardGame\Account\TriedOpeningAccountForUnknownEntity;
6
use Stratadox\CardGame\DomainEvent;
7
use Stratadox\CardGame\Match\TriedStartingMatchForPendingProposal;
8
use Stratadox\CardGame\Proposal\TriedAcceptingExpiredProposal;
9
use Stratadox\CardGame\Proposal\TriedAcceptingUnknownProposal;
10
use Stratadox\CardGame\ReadModel\Refusals;
11
12
final class BringerOfBadNews implements EventHandler
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for class BringerOfBadNews
Loading history...
introduced by
Missing class doc comment
Loading history...
13
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class BringerOfBadNews
Loading history...
introduced by
Opening brace should be on the same line as the declaration
Loading history...
14
    private $refusals;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
Coding Style introduced by
Private member variable "refusals" must contain a leading underscore
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "refusals" must be prefixed with an underscore
Loading history...
15
16
    public function __construct(Refusals $refusals)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
introduced by
Missing function doc comment
Loading history...
17
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
18
        $this->refusals = $refusals;
19
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
20
21
    public function handle(DomainEvent $event): void
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function handle()
Loading history...
introduced by
Missing function doc comment
Loading history...
22
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
23
        if ($event instanceof TriedOpeningAccountForUnknownEntity) {
24
            $this->refusals->addFor(
25
                $event->aggregateId(),
26
                'Cannot open account for unknown entity'
27
            );
28
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
29
        if ($event instanceof TriedStartingMatchForPendingProposal) {
30
            $this->refusals->addFor(
31
                $event->aggregateId(),
32
                'The proposal is still pending!'
33
            );
34
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
35
        if ($event instanceof TriedAcceptingExpiredProposal) {
36
            $this->refusals->addFor(
37
                $event->aggregateId(),
38
                'The proposal has already expired!'
39
            );
40
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
41
        if ($event instanceof TriedAcceptingUnknownProposal) {
42
            $this->refusals->addFor(
43
                $event->aggregateId(),
44
                'Proposal not found'
45
            );
46
        }
47
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
48
}
0 ignored issues
show
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...
49