SelectableInputs::select()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
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 "SelectableInputs.php" doesn't match the expected filename "selectableinputs.php"
Loading history...
2
namespace EddIriarte\Console\Traits;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
use EddIriarte\Console\Helpers\SelectionHelper;
5
use EddIriarte\Console\Inputs\CheckboxInput;
6
use EddIriarte\Console\Inputs\RadioInput;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
trait SelectableInputs
0 ignored issues
show
Coding Style 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 trait SelectableInputs
Loading history...
12 1
    public function enableSelectHelper(InputInterface $input, OutputInterface $output)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
13
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
14 1
        $this->getHelperSet()->set(
0 ignored issues
show
Bug introduced by
It seems like getHelperSet() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
        $this->/** @scrutinizer ignore-call */ 
15
               getHelperSet()->set(
Loading history...
15 1
            new SelectionHelper($input, $output)
16
        );
17 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 enableSelectHelper()
Loading history...
18
19 2
    public function select(string $message, array $options, bool $allowMultiple = true)
0 ignored issues
show
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 true please use TRUE.
Loading history...
20
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
21 2
        $helper = $this->getHelper('selection');
0 ignored issues
show
Bug introduced by
It seems like getHelper() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        /** @scrutinizer ignore-call */ 
22
        $helper = $this->getHelper('selection');
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 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...
22 2
        $question = $allowMultiple ? new CheckboxInput($message, $options) : new RadioInput($message, $options);
0 ignored issues
show
Coding Style introduced by
The value of a comparison must not be assigned to a variable
Loading history...
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement requires brackets around comparison
Loading history...
23
24 2
        return $helper->select($question);
25
    }
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 select()
Loading history...
26
}
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...
27