CakeRequest::_environmentDetector PHP Method

_environmentDetector() protected method

Detects if a specific environment variable is present.
protected _environmentDetector ( array $detect ) : boolean
$detect array Detector options array.
return boolean Whether or not the request is the type you are checking.
    protected function _environmentDetector($detect)
    {
        if (isset($detect['env'])) {
            if (isset($detect['value'])) {
                return env($detect['env']) == $detect['value'];
            }
            if (isset($detect['pattern'])) {
                return (bool) preg_match($detect['pattern'], env($detect['env']));
            }
            if (isset($detect['options'])) {
                $pattern = '/' . implode('|', $detect['options']) . '/i';
                return (bool) preg_match($pattern, env($detect['env']));
            }
        }
        return false;
    }