src/Config/ConfigAbstract.php
final protected function getBool(string $key, bool $default = false): bool
    {
        if (!isset($this->env[$key]) or !is_string($this->env[$key])) {
            return $default;
        }

        $t = strtolower(trim($this->env[$key]));

        $allowed = [
            'true' => true,
            'on' => true,
            '1' => true,
            'false' => false,
            'off' => false,
            '0' => false,
        ];
        if (isset($allowed[$t])) {
            return $allowed[$t];
        }

        if (is_numeric($t)) {
            // if $t == 0, false is already returned.
            return true;
        }

        throw new InvalidConfigException($key, static::class);
    }
final protected function getBool(string $key, bool $default = false): bool
    {
        if (!isset($this->env[$key]) or !is_string($this->env[$key])) {
            return $default;
        }

        $t = strtolower(trim($this->env[$key]));

        $allowed = [
            'true' => true,
            'on' => true,
            '1' => true,
            'false' => false,
            'off' => false,
            '0' => false,
        ];
        if (isset($allowed[$t])) {
            return $allowed[$t];
        }

        if (is_numeric($t)) {
            // if $t == 0, false is already returned.
            return true;
        }

        throw new InvalidConfigException($key, static::class);
    }
final protected function getBool ( string $ key , bool $ default = false ) : bool { if ( ! isset ( $ this -> env [ $ key ] ) or ! is_string ( $ this -> env [ $ key ] ) ) { return $ default ; } $ t = strtolower ( trim ( $ this -> env [ $ key ] ) ) ; $ allowed = [ 'true' => true , 'on' => true , '1' => true , 'false' => false , 'off' => false , '0' => false , ] ; if ( isset ( $ allowed [ $ t ] ) ) { return $ allowed [ $ t ] ; } if ( is_numeric ( $ t ) ) { // if $t == 0, false is already returned. return true ; } throw new InvalidConfigException ( $ key , static :: class ) ; }
Get bool value from env variables.

@param string $key
@param bool $default
@return bool
Get bool value from env variables .