Skip to content

Commit 7f3886b

Browse files
committed
chore: Adjust for mago
1 parent dbb9970 commit 7f3886b

4 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/Application/UseCase/Dice/RollDice/RollDiceUseCase.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212

1313
final class RollDiceUseCase
1414
{
15-
/** @return Result<RollDiceOutput> */
15+
/**
16+
* @param RollDiceInput $input
17+
* @return Result<RollDiceOutput>
18+
* @throws \Random\RandomException if the system entropy source fails.
19+
* @throws \LogicException if an invalid symbol somehow bypasses DiceModifier::fromString.
20+
*/
1621
public static function handle(RollDiceInput $input): Result
1722
{
1823
$total = 0;

src/Domain/Actions/Dice/RollDiceAction.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ final class RollDiceAction
1212
* Returns the result of rolling a dice with the given number of sides.
1313
* @param Dice $dice The dice to roll.
1414
* @return int The result of the roll.
15+
* @throws \Random\RandomException if the system entropy source fails.
1516
*/
1617
public static function roll(Dice $dice): int
1718
{

src/Domain/Entities/Session.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,10 @@ final class Session
1212
* @param string $name The name of the session
1313
* @param Identifier $identifier The unique identifier for the session
1414
* @param \DateTime $createdAt The date and time when the session was created
15-
* @throws \InvalidArgumentException if the session name is empty
1615
*/
1716
public function __construct(
1817
public readonly string $name,
1918
public readonly Identifier $identifier,
2019
public readonly \DateTime $createdAt,
21-
) {
22-
if (empty($name)) {
23-
throw new \InvalidArgumentException('Session name cannot be empty');
24-
}
25-
}
20+
) {}
2621
}

src/Domain/ValueObjects/DiceModifier.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ public static function fromString(string $modifier): self
4545
/**
4646
* @param int $rollValue
4747
* @return int
48+
* @throws \LogicException if an invalid symbol somehow bypasses fromString
4849
*/
4950
public function apply(int $rollValue): int
5051
{
5152
return (int) ceil(match ($this->symbol) {
5253
'+' => $rollValue + $this->value,
5354
'-' => $rollValue - $this->value,
5455
'*', 'x' => $rollValue * $this->value,
55-
'/' => $this->value !== 0 ? $rollValue / $this->value : $rollValue,
56+
'/' => $rollValue / $this->value,
57+
default => throw new \LogicException("Unexpected symbol: {$this->symbol}"),
5658
});
5759
}
5860
}

0 commit comments

Comments
 (0)