HEX
Server: Apache
System: Linux webm004.cluster121.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
User: grainesdfo (155059)
PHP: 5.4.45
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/grainesdfo/www/wp-content/plugins/backwpup/vendor/inpsyde/backwpup-archiver/src/Factory.php
<?php

/*
 * This file is part of the BackWPup Archiver package.
 *
 * (c) Inpsyde <hello@inpsyde.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Inpsyde\BackWPup\Archiver;

use InvalidArgumentException;
use PclZip;
use ZipArchive;
use Inpsyde\Assert\Assert;

/**
 * Class Factory
 *
 * @author Guido Scialfa <dev@guidoscialfa.com>
 */
class Factory
{
    /**
     * Create instance of Archive Operator
     *
     * Try to create Zip because of ZipArchive take precedence, if ZipArchive class
     * doesn't exists, fallback to FallBackZip the wrapper for PclZip.
     *
     * @param string $fileName
     * @return ArchiveFileOperator
     * @throws InvalidArgumentException
     */
    public function create($fileName)
    {
        Assert::stringNotEmpty($fileName);

        if (class_exists('ZipArchive')) {
            return new Zip(new ZipArchive(), $fileName);
        }

        if (!class_exists('PclZip')) {
            require_once dirname(__DIR__) . '/lib/pclzip.lib.php';
        }

        return new FallBackZip(new PclZip($fileName), $fileName);
    }
}