Skip to content

Commit 3bdb5b8

Browse files
committed
Run inspections
1 parent 5ab9939 commit 3bdb5b8

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/CommandParser.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function findApplicableStrategy(Command $commandObject, array $par
3636
}
3737
}
3838

39-
throw new NoApplicableStrategiesException();
39+
throw new NoApplicableStrategiesException('No applicable strategies were found');
4040
}
4141

4242
/**
@@ -50,12 +50,12 @@ public static function parseFromString(string $string, string $prefix = '!'): Pa
5050
$messageParts = explode(' ', trim($string));
5151
$firstPart = array_shift($messageParts);
5252

53-
if (strlen($firstPart) == strlen($prefix)) {
54-
throw new ParseException();
53+
if (strlen($firstPart) === strlen($prefix)) {
54+
throw new ParseException('This command consists of only a command prefix');
5555
}
5656

57-
if (substr($firstPart, 0, strlen($prefix)) != $prefix) {
58-
throw new ParseException();
57+
if (strpos($firstPart, $prefix) !== 0) {
58+
throw new ParseException('The command prefix is not at the beginning of the given command');
5959
}
6060

6161
$command = substr($firstPart, strlen($prefix));

src/CommandProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function findCommand(string $command): Command
7171
$dictionary = $this->getCommandCollection();
7272

7373
if (!$dictionary->offsetExists($command)) {
74-
throw new Exceptions\CommandNotFoundException();
74+
throw new CommandNotFoundException('The given command was not (yet) registered in the CommandProcessor');
7575
}
7676

7777
/** @var Command $commandObject */

src/ParameterStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function validateParameterArray(array $args): bool
9090
$names = array_keys((array)$this);
9191

9292
if (!$this->validateParameterCount($args)) {
93-
throw new InvalidParameterCountException();
93+
throw new InvalidParameterCountException('The command has an unsatisfactory amount of parameters');
9494
}
9595

9696
if ($this->shouldConcatLeftover()) {

src/Parameters/PredefinedStringParameter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class PredefinedStringParameter extends Parameter
1818
*/
1919
public function __construct(string $expected)
2020
{
21-
parent::__construct(function (string $value) use ($expected) {
22-
return $value == $expected;
21+
parent::__construct(static function (string $value) use ($expected) {
22+
return $value === $expected;
2323
});
2424
}
2525
}

0 commit comments

Comments
 (0)