PHP 8.3.31
Preview: MultipleInstanceManager.php Size: 5.16 KB
/home/getspomw/royalsquad.us/vendor/laravel/framework/src/Illuminate/Support/MultipleInstanceManager.php

<?php

namespace Illuminate\Support;

use Closure;
use InvalidArgumentException;
use RuntimeException;

abstract class MultipleInstanceManager
{
    /**
     * The application instance.
     *
     * @var \Illuminate\Contracts\Foundation\Application
     */
    protected $app;

    /**
     * The configuration repository instance.
     *
     * @var \Illuminate\Contracts\Config\Repository
     */
    protected $config;

    /**
     * The array of resolved instances.
     *
     * @var array
     */
    protected $instances = [];

    /**
     * The registered custom instance creators.
     *
     * @var array
     */
    protected $customCreators = [];

    /**
     * The key name of the "driver" equivalent configuration option.
     *
     * @var string
     */
    protected $driverKey = 'driver';

    /**
     * Create a new manager instance.
     *
     * @param  \Illuminate\Contracts\Foundation\Application  $app
     * @return void
     */
    public function __construct($app)
    {
        $this->app = $app;
        $this->config = $app->make('config');
    }

    /**
     * Get the default instance name.
     *
     * @return string
     */
    abstract public function getDefaultInstance();

    /**
     * Set the default instance name.
     *
     * @param  string  $name
     * @return void
     */
    abstract public function setDefaultInstance($name);

    /**
     * Get the instance specific configuration.
     *
     * @param  string  $name
     * @return array
     */
    abstract public function getInstanceConfig($name);

    /**
     * Get an instance by name.
     *
     * @param  string|null  $name
     * @return mixed
     */
    public function instance($name = null)
    {
        $name = $name ?: $this->getDefaultInstance();

        return $this->instances[$name] = $this->get($name);
    }

    /**
     * Attempt to get an instance from the local cache.
     *
     * @param  string  $name
     * @return mixed
     */
    protected function get($name)
    {
        return $this->instances[$name] ?? $this->resolve($name);
    }

    /**
     * Resolve the given instance.
     *
     * @param  string  $name
     * @return mixed
     *
     * @throws \InvalidArgumentException
     * @throws \RuntimeException
     */
    protected function resolve($name)
    {
        $config = $this->getInstanceConfig($name);

        if (is_null($config)) {
            throw new InvalidArgumentException("Instance [{$name}] is not defined.");
        }

        if (! array_key_exists($this->driverKey, $config)) {
            throw new RuntimeException("Instance [{$name}] does not specify a {$this->driverKey}.");
        }

        $driverName = $config[$this->driverKey];

        if (isset($this->customCreators[$driverName])) {
            return $this->callCustomCreator($config);
        } else {
            $createMethod = 'create'.ucfirst($driverName).ucfirst($this->driverKey);

            if (method_exists($this, $createMethod)) {
                return $this->{$createMethod}($config);
            }

            $createMethod = 'create'.Str::studly($driverName).ucfirst($this->driverKey);

            if (method_exists($this, $createMethod)) {
                return $this->{$createMethod}($config);
            }

            throw new InvalidArgumentException("Instance {$this->driverKey} [{$config[$this->driverKey]}] is not supported.");
        }
    }

    /**
     * Call a custom instance creator.
     *
     * @param  array  $config
     * @return mixed
     */
    protected function callCustomCreator(array $config)
    {
        return $this->customCreators[$config[$this->driverKey]]($this->app, $config);
    }

    /**
     * Unset the given instances.
     *
     * @param  array|string|null  $name
     * @return $this
     */
    public function forgetInstance($name = null)
    {
        $name ??= $this->getDefaultInstance();

        foreach ((array) $name as $instanceName) {
            if (isset($this->instances[$instanceName])) {
                unset($this->instances[$instanceName]);
            }
        }

        return $this;
    }

    /**
     * Disconnect the given instance and remove from local cache.
     *
     * @param  string|null  $name
     * @return void
     */
    public function purge($name = null)
    {
        $name ??= $this->getDefaultInstance();

        unset($this->instances[$name]);
    }

    /**
     * Register a custom instance creator Closure.
     *
     * @param  string  $name
     * @param  \Closure  $callback
     * @return $this
     */
    public function extend($name, Closure $callback)
    {
        $this->customCreators[$name] = $callback->bindTo($this, $this);

        return $this;
    }

    /**
     * Set the application instance used by the manager.
     *
     * @param  \Illuminate\Contracts\Foundation\Application  $app
     * @return $this
     */
    public function setApplication($app)
    {
        $this->app = $app;

        return $this;
    }

    /**
     * Dynamically call the default instance.
     *
     * @param  string  $method
     * @param  array  $parameters
     * @return mixed
     */
    public function __call($method, $parameters)
    {
        return $this->instance()->$method(...$parameters);
    }
}

Directory Contents

Dirs: 6 × Files: 38

Name Size Perms Modified Actions
Defer DIR
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
Facades DIR
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
Process DIR
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
Testing DIR
- drwxrwxrwx 2025-09-17 06:53:01
Edit Download
Traits DIR
- drwxrwxrwx 2025-09-17 06:53:02
Edit Download
995 B lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
1.94 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
898 B lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
1.98 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
6.79 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
4.25 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
7.76 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
3.15 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
2.96 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
6.27 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
1.34 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
12.93 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
665 B lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
1.07 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
2.09 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
3.47 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
1.05 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
5.87 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
4.42 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
10.03 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
5.16 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
3.35 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
10.60 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
1.88 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
2.05 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
2.64 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
2.84 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
2.00 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
4.50 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
14.67 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
11.78 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
57.38 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
34.67 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
1.66 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
9.68 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
1.95 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
4.55 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download
2.59 KB lrw-rw-rw- 2025-09-17 06:53:01
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).