for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Dgame\Ensurance\Enforcement;
use Throwable;
/**
* Trait EnforcementTrait
* @package Dgame\Ensurance\Enforcement
*/
trait EnforcementTrait
{
* @var Enforcement|null
private $enforcement;
* @param string|Throwable $throwable
* @param array ...$args
*
* @return $this
$args
array[]
final public function orThrow($throwable, ...$args)
if ($this->hasEnforcement()) {
$this->enforcement->orThrow($throwable, ...$args);
}
return $this;
* @return bool
final public function verify(): bool
if (!$this->isEnforcementFulfilled()) {
$this->approveEnforcement();
return false;
return true;
* @param bool $condition
final protected function enforce(bool $condition)
$this->enforcement = new Enforcement($condition);
private function approveEnforcement()
$this->enforcement->approve();
final protected function isEnforcementFulfilled(): bool
return $this->hasEnforcement() && $this->enforcement->isFulfilled();
private function hasEnforcement(): bool
return $this->enforcement !== null;