ManyToOneTransition   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 86.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 42
ccs 13
cts 15
cp 0.8667
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getName() 0 3 1
A getDestinationState() 0 3 1
A onRegister() 0 7 2
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 "ManyToOneTransition.php" doesn't match the expected filename "manytoonetransition.php"
Loading history...
2
3
namespace Star\Component\State\Transitions;
4
5
use Star\Component\State\RegistryBuilder;
6
use Star\Component\State\StateTransition;
7
use Webmozart\Assert\Assert;
8
9
final class ManyToOneTransition implements StateTransition
0 ignored issues
show
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
10
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class ManyToOneTransition
Loading history...
11
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
12
     * @var string
13
     */
14
    private $name;
0 ignored issues
show
Coding Style introduced by
Private member variable "name" 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 "name" must be prefixed with an underscore
Loading history...
15
16
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
17
     * @var string[]
18
     */
19
    private $fromStates;
0 ignored issues
show
Coding Style introduced by
Private member variable "fromStates" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "fromStates" must be prefixed with an underscore
Loading history...
20
21
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
22
     * @var string
23
     */
24
    private $to;
0 ignored issues
show
Coding Style introduced by
Private member variable "to" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "to" must be prefixed with an underscore
Loading history...
25
26 20
    public function __construct(string $name, string $to, string ...$fromStates)
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...
27
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
28 20
        $this->name = $name;
29 20
        Assert::greaterThanEq(\count($fromStates), 1, 'Expected at least %2$s state. Got: %s');
30 20
        $this->fromStates = $fromStates;
31 20
        $this->to = $to;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
32 20
    }
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...
33
34 18
    public function getName(): string
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
35
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
36 18
        return $this->name;
37
    }
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 getName()
Loading history...
38
39 18
    public function onRegister(RegistryBuilder $registry): void
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
40
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
41 18
        foreach ($this->fromStates as $from) {
42 18
            $registry->registerStartingState($this->name, $from, []);
0 ignored issues
show
Coding Style introduced by
Short array syntax is not allowed
Loading history...
43
        }
44
45 18
        $registry->registerDestinationState($this->name, $this->to, []);
0 ignored issues
show
Coding Style introduced by
Short array syntax is not allowed
Loading history...
46 18
    }
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 onRegister()
Loading history...
47
48
    public function getDestinationState(): string
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
49
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
50
        return $this->to;
51
    }
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 getDestinationState()
Loading history...
52
}
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...
53