for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Equip\ValueObject;
use InvalidArgumentException;
class Flag
{
private $value;
public function __construct($value, $default = null)
static $empty_values = [null, ''];
if (is_bool($default) && in_array($value, $empty_values, true)) {
$value = $default;
}
$options = [
'flags' => \FILTER_NULL_ON_FAILURE | \FILTER_REQUIRE_SCALAR,
];
$value = filter_var($value, \FILTER_VALIDATE_BOOLEAN, $options);
if ($value === null) {
throw new InvalidArgumentException('Value must be boolean flag');
$this->value = $value;
public function value()
return $this->value;