for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace Stratadox\CardGame\Match;
use DateTimeInterface;
final class Turn
{
private $currentPlayer;
private $since;
private $canPlay;
private $canDefend;
public function __construct(int $player, DateTimeInterface $since, bool $play = true)
$this->currentPlayer = $player;
$this->since = $since;
$this->canPlay = $play;
$this->canDefend = !$play;
}
public function prohibitsPlaying(int $player, DateTimeInterface $when): bool
return $this->currentPlayer !== $player ||
!$this->canPlay ||
$when->getTimestamp() - $this->since->getTimestamp() >= 20;
public function prohibitsAttacking(int $player, DateTimeInterface $when): bool
$when
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function prohibitsAttacking(int $player, /** @scrutinizer ignore-unused */ DateTimeInterface $when): bool
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return $this->currentPlayer !== $player;
public function prohibitsDefending(int $player, DateTimeInterface $when): bool
!$this->canDefend ||
public function endCardPlayingPhaseFor(int $thePlayer): Turn
$thePlayer
public function endCardPlayingPhaseFor(/** @scrutinizer ignore-unused */ int $thePlayer): Turn
// @todo
$this->canPlay = false;
return $this;
public function endCombatPhase(): Turn
// @todo add time
$this->canDefend = false;
$this->canPlay = true;
public function of(int $thePlayer, DateTimeInterface $since): Turn
return new Turn($thePlayer, $since, false);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.