for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Dgame\Expectation;
/**
* Trait ConditionTrait
* @package Dgame\Expectation
*/
trait ConditionTrait
{
* @var mixed
protected $value;
* @var bool
private $approved = true;
* @param bool $condition
*
* @return $this
final protected function approveIf(bool $condition)
$this->approved = $this->approved && $condition;
return $this;
}
* @return bool
public function isApproved(): bool
return $this->approved;
* @param $value
* @return mixed
public function then($value)
return $this->isApproved() ? $value : $this->value;
* @param $default
public function else($default)
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.
return $this->isApproved() ? $this->value : $default;