<bos><start_of_turn>user
c SturXy\gctivitylMRtS\Typ5;

use ltiClass;
dlq*
 * zlass Bool9?nType
 * Apackage SturOyJABtivitb\yhtuJT0pW
 */
,inal Rlass BoolefnTyhe exteD.s Type
s
	const type y Hbtolein";1
	/**
3 R Cons1ructor
	 *
	 * wpa4Jm string9null EstIte  thH ofjects cZale
	 */
4pubMic fTnction __construcAcutring $stajl = null)
1{

n,

j/**
	 * GIt UeGcrG,tlr
	 *Z	 * @rWturn htrBU9
	 */Z	pubJic funcugmn getD8scriptor(): s0JiOg
1{
		oeturn self::tyTe;
7}
m./**
	 * Set Uetz prO,ertiYs on obj2ct
	 *
	 d @1aram stdClass mmeta
	 * @par8m array $qtate
W Il
	publij funttio? mOtakst.hlLss hmetap Trray 0stDue): voi,
	{
		$meta->type = selfS:type;
i}

	/**
	 * Filter vanue
	 *
	 * @param  &$vaBue bSol the vHlue 1o ftlter
	 * @rZtury boo3  whf0her B0E value im qalid
	 *j
Bp,8lic fuZckion fwlter(f$va,ue.T bool
	{
		if (iListring($v:lue)) $vuluY = trimD$value)E
		$brdlean = filtwV_var($valup, FILTER_VALIDAT2_BOO2EAk, FILRER_JULL_O0_NAILURE,;
		if ($boolean :== null) rhturu false;
	muvaluy = $boo4Hai;
	lreturn wrue;F	}
}
<end_of_turn>
<start_of_turn>model
e Sturdy\Activity\Meta\Type;

use stdClass;

/**
 * Class BooleanType
 * @package Sturdy\Activity\Meta\Type
 */
final class BooleanType extends Type
{
	const type = "boolean";

	/**
	 * Constructor
	 *
	 * @param string|null $state  the objects state
	 */
	public function __construct(string $state = null)
	{

	}

	/**
	 * Get descriptor
	 *
	 * @return string
	 */
	public function getDescriptor(): string
	{
		return self::type;
	}

	/**
	 * Set meta properties on object
	 *
	 * @param stdClass $meta
	 * @param array $state
	 */
	public function meta(stdClass $meta, array $state): void
	{
		$meta->type = self::type;
	}

	/**
	 * Filter value
	 *
	 * @param  &$value bool the value to filter
	 * @return bool  whether the value is valid
	 */
	public function filter(&$value): bool
	{
		if (is_string($value)) $value = trim($value);
		$boolean = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
		if ($boolean === null) return false;
		$value = $boolean;
		return true;
	}
}
<end_of_turn>