CallClosureOnFailure   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 40
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A onFailure() 0 5 1
A afterStateChange() 0 2 1
A beforeStateChange() 0 2 1
A __construct() 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 "CallClosureOnFailure.php" doesn't match the expected filename "callclosureonfailure.php"
Loading history...
2
3
namespace Star\Component\State\Callbacks;
4
5
use Star\Component\State\InvalidStateTransitionException;
6
use Star\Component\State\StateMachine;
7
8
final class CallClosureOnFailure implements TransitionCallback
0 ignored issues
show
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
9
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class CallClosureOnFailure
Loading history...
10
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
11
     * @var \Closure
12
     */
13
    private $callback;
0 ignored issues
show
Coding Style introduced by
Private member variable "callback" 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 "callback" must be prefixed with an underscore
Loading history...
14
15 1
    public function __construct(\Closure $callback)
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...
16
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
17 1
        $this->callback = $callback;
18 1
    }
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...
19
20
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
     * @param mixed $context
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
22
     * @param StateMachine $machine
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
23
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
24 1
    public function beforeStateChange($context, StateMachine $machine): void
25
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
26 1
    }
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 beforeStateChange()
Loading history...
27
28
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
29
     * @param mixed $context
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
30
     * @param StateMachine $machine
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
31
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
32 1
    public function afterStateChange($context, StateMachine $machine): void
33
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
34 1
    }
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 afterStateChange()
Loading history...
35
36
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
37
     * @param InvalidStateTransitionException $exception
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
38
     * @param mixed $context
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 27 spaces after parameter type; 1 found
Loading history...
39
     * @param StateMachine $machine
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 20 spaces after parameter type; 1 found
Loading history...
40
     *
41
     * @return string
42
     */
43 1
    public function onFailure(InvalidStateTransitionException $exception, $context, StateMachine $machine): string
0 ignored issues
show
Unused Code introduced by
The method parameter $exception is never used
Loading history...
Unused Code introduced by
The method parameter $machine is never used
Loading history...
44
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
45 1
        $callback = $this->callback;
46
47 1
        return $callback($context);
48
    }
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 onFailure()
Loading history...
49
}
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...
50