public function toBoolean()
    {
        $key = $this->toLowerCase()->scalarString;

        $map =
        [
            'true'  => true,
            '1'     => true,
            'on'    => true,
            'yes'   => true,
            'false' => false,
            '0'     => false,
            'off'   => false,
            'no'    => false
        ];

        if (array_key_exists($key, $map))
        {
            return $map[$key];
        }
        elseif (is_numeric($this->scalarString))
        {
            return ((int)$this->scalarString > 0);
        }
        else
        {
            return (bool)$this->regexReplace('[[:space:]]', '')->scalarString;
        }
    }
public function toBoolean()
    {
        $key = $this->toLowerCase()->scalarString;

        $map =
        [
            'true'  => true,
            '1'     => true,
            'on'    => true,
            'yes'   => true,
            'false' => false,
            '0'     => false,
            'off'   => false,
            'no'    => false
        ];

        if (array_key_exists($key, $map))
        {
            return $map[$key];
        }
        elseif (is_numeric($this->scalarString))
        {
            return ((int)$this->scalarString > 0);
        }
        else
        {
            return (bool)$this->regexReplace('[[:space:]]', '')->scalarString;
        }
    }
public function toBoolean ( ) { $ key = $ this -> toLowerCase ( ) -> scalarString ; $ map = [ 'true' => true , '1' => true , 'on' => true , 'yes' => true , 'false' => false , '0' => false , 'off' => false , 'no' => false ] ; if ( array_key_exists ( $ key , $ map ) ) { return $ map [ $ key ] ; } elseif ( is_numeric ( $ this -> scalarString ) ) { return ( ( int ) $ this -> scalarString > 0 ) ; } else { return ( bool ) $ this -> regexReplace ( '[[:space:]]' , '' ) -> scalarString ; } }
Returns a boolean representation of the given logical string value.

For example, 'true', '1', 'on' and 'yes' will return true. 'false', '0',
'off', and 'no' will return false. In all instances, case is ignored.
For other numeric strings, their sign will determine the return value.
In addition, blank strings consisting of only whitespace will return
false. For all other strings, the return value is a result of a
boolean cast.

@return bool
Returns a boolean representation of the given logical string value .