public function getMode($throwException = false, $forceMode = false)
    {
        if (false === $this->enabled && true !== $forceMode) {
            return new NullMode();
        }

        switch ($this->type) {
            case 'nginx':
            case 'sendfile':
            case 'xaccel':
            case 'xaccelredirect':
            case 'x-accel':
            case 'x-accel-redirect':
                if (2 >= count($this->mapping)) {
                    $this->logger->error('Invalid xsendfile mapping configuration.');
                    if ($throwException) {
                        throw new RuntimeException('Mapping is not set up.');
                    }
                }

                return new NginxMode($this->mapping);
            case 'apache':
            case 'apache2':
            case 'xsendfile':
                return new ApacheMode($this->mapping);
            default:
                $this->logger->error('Invalid xsendfile type configuration.');
                if ($throwException) {
                    throw new InvalidArgumentException(sprintf(
                        'Invalid xsendfile type value "%s"',
                        $this->type
                    ));
                }

                return new NullMode();
        }
    }