FOF30\Input\Input::__construct PHP Method

__construct() public method

Public constructor. Overridden to allow specifying the global input array to use as a string and instantiate from an object holding variables.
public __construct ( array | string | object | null $source = null, array $options = [] )
$source array | string | object | null Source data; set null to use $_REQUEST
$options array Filter options
    public function __construct($source = null, array $options = array())
    {
        $hash = null;
        if (is_string($source)) {
            $hash = strtoupper($source);
            switch ($hash) {
                case 'GET':
                    $source = $_GET;
                    break;
                case 'POST':
                    $source = $_POST;
                    break;
                case 'FILES':
                    $source = $_FILES;
                    break;
                case 'COOKIE':
                    $source = $_COOKIE;
                    break;
                case 'ENV':
                    $source = $_ENV;
                    break;
                case 'SERVER':
                    $source = $_SERVER;
                    break;
                default:
                    $source = $_REQUEST;
                    $hash = 'REQUEST';
                    break;
            }
        } elseif (is_object($source) && $source instanceof Input) {
            $source = $source->getData();
        } elseif (is_object($source) && $source instanceof \JInput) {
            $serialised = $source->serialize();
            list($xOptions, $xData, $xInput) = unserialize($serialised);
            unset($xOptions);
            unset($xInput);
            unset($source);
            $source = $xData;
            unset($xData);
        } elseif (is_object($source)) {
            try {
                $source = (array) $source;
            } catch (\Exception $exc) {
                $source = null;
            }
        } elseif (is_array($source)) {
            // Nothing, it's already an array
        } else {
            // Any other case
            $source = null;
        }
        // If we are not sure use the REQUEST array
        if (empty($source)) {
            $source = $_REQUEST;
            $hash = 'REQUEST';
        }
        // Magic quotes GPC handling (something JInput simply can't handle at all)
        // @codeCoverageIgnoreStart
        if ($hash == 'REQUEST' && get_magic_quotes_gpc() && class_exists('\\JRequest', true)) {
            $source = \JRequest::get('REQUEST', 2);
        }
        // @codeCoverageIgnoreEnd
        parent::__construct($source, $options);
    }