����JFIF��x�x����'
| Server IP : 78.140.185.180  /  Your IP : 216.73.216.38 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/builderbox/././././././public_html/common/Settings/Validators/  | 
Upload File :  | 
<?php
namespace Common\Settings\Validators;
use Cache;
use Carbon\Carbon;
use Common\Settings\DotEnvEditor;
use Exception;
use Throwable;
use Illuminate\Support\Arr;
class CacheConfigValidator
{
    const KEYS = ['cache_driver'];
    public function fails($settings)
    {
        $this->setConfigDynamically($settings);
        try {
            $driverName = Arr::get($settings, 'cache_driver', config('cache.default'));
            $driver = Cache::driver($driverName);
            $driver->put('foo', 'bar', 1);
            if ($driver->get('foo') !== 'bar') {
                return $this->getDefaultErrorMessage();
            }
        } catch (Exception $e) {
            return $this->getErrorMessage($e);
        } catch (Throwable $e) {
            return $this->getErrorMessage($e);
        }
    }
    private function setConfigDynamically($settings)
    {
        app(DotEnvEditor::class)->write(Arr::except($settings, ['cache_driver']));
    }
    /**
     * @param Exception|Throwable $e
     * @return array
     */
    private function getErrorMessage($e)
    {
        $message = $e->getMessage();
        if (\Str::contains($message, 'apc_fetch')) {
            return ['cache_group' => "Could not enable APC. $message"];
        } else if (\Str::contains($message, 'Memcached')) {
            return ['cache_group' => "Could not enable Memcached. $message"];
        } else if (\Str::contains($message, 'Connection refused')) {
            return ['cache_group' => 'Could not connect to redis server.'];
        } else {
            return $this->getDefaultErrorMessage();
        }
    }
    /**
     * @return array
     */
    private function getDefaultErrorMessage()
    {
        return ['cache_group' => 'Could not enable this cache method.'];
    }
}