public function setRequiredType($type)
    {
        if (!in_array($type, array('file', 'directory'))) {
            throw new \InvalidArgumentException("Input type must be either 'file' or 'directory'.");
        }

        if ($type === 'directory') {
            $this->setAllowDirectory(true);
        } else {
            $this->setAllowDirectory(false);
        }

        $this->requiredType = $type;

        return $this;
    }