private static function convertMode($mode)
    {
        if (is_string($mode)) {
            $mode = defined('\Tideways\Profiler::MODE_' . strtoupper($mode))
                ? constant('\Tideways\Profiler::MODE_' . strtoupper($mode))
                : self::MODE_DISABLED;
        } else if (!is_int($mode)) {
            $mode = self::MODE_DISABLED;
        } else if (($mode & (self::MODE_FULL|self::MODE_BASIC)) === 0) {
            $mode = self::MODE_DISABLED;
        }

        return $mode;
    }