protected function setFilename($filename)
    {
        if (is_string($filename)) {
            if (is_readable($filename)) {
                $this->filename = $filename;
            } elseif (file_exists($filename)) {
                throw new \InvalidArgumentException("File '$filename' isn't readable.");
            } else {
                throw new \InvalidArgumentException("File '$filename' doesn't exist.");
            }
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($filename). "' for argument 'filename' given."
            );
        }

        return $this;
    }