eddiriarte /
console-select
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | namespace EddIriarte\Console\Inputs; |
||
|
0 ignored issues
–
show
|
|||
| 3 | |||
| 4 | use EddIriarte\Console\Inputs\Traits\ChunkableOptions; |
||
| 5 | use EddIriarte\Console\Inputs\Interfaces\SelectInput; |
||
| 6 | |||
| 7 | |||
| 8 | /** |
||
| 9 | * Class AbstractSelect |
||
| 10 | * @package EddIriarte\Console\Inputs |
||
|
0 ignored issues
–
show
|
|||
| 11 | * @author Eduardo Iriarte <eddiriarte[at]gmail[dot]com> |
||
|
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
|
|||
| 12 | */ |
||
|
0 ignored issues
–
show
|
|||
| 13 | abstract class AbstractSelect implements SelectInput |
||
| 14 | { |
||
|
0 ignored issues
–
show
|
|||
| 15 | use ChunkableOptions; |
||
| 16 | |||
| 17 | protected $message; |
||
|
0 ignored issues
–
show
|
|||
| 18 | |||
| 19 | protected $options; |
||
|
0 ignored issues
–
show
|
|||
| 20 | |||
| 21 | protected $selections; |
||
|
0 ignored issues
–
show
|
|||
| 22 | |||
| 23 | /** |
||
| 24 | * AbstractSelect constructor. |
||
| 25 | * |
||
| 26 | * @param string $message |
||
|
0 ignored issues
–
show
|
|||
| 27 | * @param array $options |
||
|
0 ignored issues
–
show
|
|||
| 28 | */ |
||
| 29 | 18 | public function __construct(string $message, array $options) |
|
|
0 ignored issues
–
show
|
|||
| 30 | { |
||
|
0 ignored issues
–
show
|
|||
| 31 | 18 | $this->message = $message; |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 4 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 | 18 | $this->options = $options; |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 4 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...
|
|||
| 33 | 18 | $this->selections = []; |
|
|
0 ignored issues
–
show
|
|||
| 34 | 18 | } |
|
|
0 ignored issues
–
show
|
|||
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritdoc} |
||
| 38 | */ |
||
|
0 ignored issues
–
show
|
|||
| 39 | 7 | public function getMessage(): string |
|
| 40 | { |
||
|
0 ignored issues
–
show
|
|||
| 41 | 7 | return $this->message; |
|
| 42 | } |
||
|
0 ignored issues
–
show
|
|||
| 43 | |||
| 44 | /** |
||
|
0 ignored issues
–
show
|
|||
| 45 | * @return array |
||
| 46 | */ |
||
| 47 | 9 | public function getOptions(): array |
|
| 48 | { |
||
|
0 ignored issues
–
show
|
|||
| 49 | 9 | return $this->options; |
|
| 50 | } |
||
|
0 ignored issues
–
show
|
|||
| 51 | |||
| 52 | /** |
||
|
0 ignored issues
–
show
|
|||
| 53 | * @return array |
||
| 54 | */ |
||
| 55 | 9 | public function getSelections(): array |
|
| 56 | { |
||
|
0 ignored issues
–
show
|
|||
| 57 | 9 | return $this->selections; |
|
| 58 | } |
||
|
0 ignored issues
–
show
|
|||
| 59 | |||
| 60 | /** |
||
|
0 ignored issues
–
show
|
|||
| 61 | * @return bool |
||
|
0 ignored issues
–
show
|
|||
| 62 | */ |
||
| 63 | 1 | public function hasSelections(): bool |
|
| 64 | { |
||
|
0 ignored issues
–
show
|
|||
| 65 | 1 | return !empty($this->selections); |
|
|
0 ignored issues
–
show
|
|||
| 66 | } |
||
|
0 ignored issues
–
show
|
|||
| 67 | |||
| 68 | /** |
||
|
0 ignored issues
–
show
|
|||
| 69 | * @param string $option |
||
|
0 ignored issues
–
show
|
|||
| 70 | * @return bool |
||
|
0 ignored issues
–
show
|
|||
| 71 | */ |
||
| 72 | 10 | public function isSelected(string $option): bool |
|
| 73 | { |
||
|
0 ignored issues
–
show
|
|||
| 74 | 10 | return (bool) in_array($option, $this->selections); |
|
|
0 ignored issues
–
show
|
|||
| 75 | } |
||
|
0 ignored issues
–
show
|
|||
| 76 | } |
||
|
0 ignored issues
–
show
|
|||
| 77 |