/home/mip/www/vendor/laravel-filemanager/files/folder-1/821668/graham-campbell.zip
PK �8]�F��X X result-type/LICENSEnu �[��� The MIT License (MIT)
Copyright (c) 2020-2023 Graham Campbell <hello@gjcampbell.co.uk>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
PK �8]�usܕ � result-type/src/Success.phpnu �[��� <?php
declare(strict_types=1);
/*
* This file is part of Result Type.
*
* (c) Graham Campbell <hello@gjcampbell.co.uk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace GrahamCampbell\ResultType;
use PhpOption\None;
use PhpOption\Some;
/**
* @template T
* @template E
*
* @extends \GrahamCampbell\ResultType\Result<T,E>
*/
final class Success extends Result
{
/**
* @var T
*/
private $value;
/**
* Internal constructor for a success value.
*
* @param T $value
*
* @return void
*/
private function __construct($value)
{
$this->value = $value;
}
/**
* Create a new error value.
*
* @template S
*
* @param S $value
*
* @return \GrahamCampbell\ResultType\Result<S,E>
*/
public static function create($value)
{
return new self($value);
}
/**
* Get the success option value.
*
* @return \PhpOption\Option<T>
*/
public function success()
{
return Some::create($this->value);
}
/**
* Map over the success value.
*
* @template S
*
* @param callable(T):S $f
*
* @return \GrahamCampbell\ResultType\Result<S,E>
*/
public function map(callable $f)
{
return self::create($f($this->value));
}
/**
* Flat map over the success value.
*
* @template S
* @template F
*
* @param callable(T):\GrahamCampbell\ResultType\Result<S,F> $f
*
* @return \GrahamCampbell\ResultType\Result<S,F>
*/
public function flatMap(callable $f)
{
return $f($this->value);
}
/**
* Get the error option value.
*
* @return \PhpOption\Option<E>
*/
public function error()
{
return None::create();
}
/**
* Map over the error value.
*
* @template F
*
* @param callable(E):F $f
*
* @return \GrahamCampbell\ResultType\Result<T,F>
*/
public function mapError(callable $f)
{
return self::create($this->value);
}
}
PK �8]��{� � result-type/src/Error.phpnu �[��� <?php
declare(strict_types=1);
/*
* This file is part of Result Type.
*
* (c) Graham Campbell <hello@gjcampbell.co.uk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace GrahamCampbell\ResultType;
use PhpOption\None;
use PhpOption\Some;
/**
* @template T
* @template E
*
* @extends \GrahamCampbell\ResultType\Result<T,E>
*/
final class Error extends Result
{
/**
* @var E
*/
private $value;
/**
* Internal constructor for an error value.
*
* @param E $value
*
* @return void
*/
private function __construct($value)
{
$this->value = $value;
}
/**
* Create a new error value.
*
* @template F
*
* @param F $value
*
* @return \GrahamCampbell\ResultType\Result<T,F>
*/
public static function create($value)
{
return new self($value);
}
/**
* Get the success option value.
*
* @return \PhpOption\Option<T>
*/
public function success()
{
return None::create();
}
/**
* Map over the success value.
*
* @template S
*
* @param callable(T):S $f
*
* @return \GrahamCampbell\ResultType\Result<S,E>
*/
public function map(callable $f)
{
return self::create($this->value);
}
/**
* Flat map over the success value.
*
* @template S
* @template F
*
* @param callable(T):\GrahamCampbell\ResultType\Result<S,F> $f
*
* @return \GrahamCampbell\ResultType\Result<S,F>
*/
public function flatMap(callable $f)
{
/** @var \GrahamCampbell\ResultType\Result<S,F> */
return self::create($this->value);
}
/**
* Get the error option value.
*
* @return \PhpOption\Option<E>
*/
public function error()
{
return Some::create($this->value);
}
/**
* Map over the error value.
*
* @template F
*
* @param callable(E):F $f
*
* @return \GrahamCampbell\ResultType\Result<T,F>
*/
public function mapError(callable $f)
{
return self::create($f($this->value));
}
}
PK �8]�h$fZ Z result-type/src/Result.phpnu �[��� <?php
declare(strict_types=1);
/*
* This file is part of Result Type.
*
* (c) Graham Campbell <hello@gjcampbell.co.uk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace GrahamCampbell\ResultType;
/**
* @template T
* @template E
*/
abstract class Result
{
/**
* Get the success option value.
*
* @return \PhpOption\Option<T>
*/
abstract public function success();
/**
* Map over the success value.
*
* @template S
*
* @param callable(T):S $f
*
* @return \GrahamCampbell\ResultType\Result<S,E>
*/
abstract public function map(callable $f);
/**
* Flat map over the success value.
*
* @template S
* @template F
*
* @param callable(T):\GrahamCampbell\ResultType\Result<S,F> $f
*
* @return \GrahamCampbell\ResultType\Result<S,F>
*/
abstract public function flatMap(callable $f);
/**
* Get the error option value.
*
* @return \PhpOption\Option<E>
*/
abstract public function error();
/**
* Map over the error value.
*
* @template F
*
* @param callable(E):F $f
*
* @return \GrahamCampbell\ResultType\Result<T,F>
*/
abstract public function mapError(callable $f);
}
PK �8]�?Q� � result-type/composer.jsonnu �[��� {
"name": "graham-campbell/result-type",
"description": "An Implementation Of The Result Type",
"keywords": ["result", "result-type", "Result", "Result Type", "Result-Type", "Graham Campbell", "GrahamCampbell"],
"license": "MIT",
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
}
],
"require": {
"php": "^7.2.5 || ^8.0",
"phpoption/phpoption": "^1.9.2"
},
"require-dev": {
"phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
},
"autoload": {
"psr-4": {
"GrahamCampbell\\ResultType\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"GrahamCampbell\\Tests\\ResultType\\": "tests/"
}
},
"config": {
"preferred-install": "dist"
}
}
PK �8]7��X X manager/LICENSEnu �[��� The MIT License (MIT)
Copyright (c) 2014-2023 Graham Campbell <hello@gjcampbell.co.uk>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
PK �8]��� � manager/src/AbstractManager.phpnu �[��� <?php
declare(strict_types=1);
/*
* This file is part of Laravel Manager.
*
* (c) Graham Campbell <hello@gjcampbell.co.uk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace GrahamCampbell\Manager;
use Closure;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Support\Arr;
use InvalidArgumentException;
/**
* This is the abstract manager class.
*
* @author Graham Campbell <hello@gjcampbell.co.uk>
*/
abstract class AbstractManager implements ManagerInterface
{
/**
* The config instance.
*
* @var \Illuminate\Contracts\Config\Repository
*/
protected Repository $config;
/**
* The active connection instances.
*
* @var array<string,object>
*/
protected array $connections = [];
/**
* The custom connection resolvers.
*
* @var array<string,callable>
*/
protected array $extensions = [];
/**
* Create a new manager instance.
*
* @param \Illuminate\Contracts\Config\Repository $config
*
* @return void
*/
public function __construct(Repository $config)
{
$this->config = $config;
}
/**
* Get a connection instance.
*
* @param string|null $name
*
* @throws \InvalidArgumentException
*
* @return object
*/
public function connection(string $name = null): object
{
$name = $name ?: $this->getDefaultConnection();
if (!isset($this->connections[$name])) {
$this->connections[$name] = $this->makeConnection($name);
}
return $this->connections[$name];
}
/**
* Reconnect to the given connection.
*
* @param string|null $name
*
* @throws \InvalidArgumentException
*
* @return object
*/
public function reconnect(string $name = null): object
{
$name = $name ?: $this->getDefaultConnection();
$this->disconnect($name);
return $this->connection($name);
}
/**
* Disconnect from the given connection.
*
* @param string|null $name
*
* @return void
*/
public function disconnect(string $name = null): void
{
$name = $name ?: $this->getDefaultConnection();
unset($this->connections[$name]);
}
/**
* Create the connection instance.
*
* @param array $config
*
* @throws \InvalidArgumentException
*
* @return object
*/
abstract protected function createConnection(array $config): object;
/**
* Make the connection instance.
*
* @param string $name
*
* @throws \InvalidArgumentException
*
* @return object
*/
protected function makeConnection(string $name): object
{
$config = $this->getConnectionConfig($name);
if (isset($this->extensions[$name])) {
return $this->extensions[$name]($config);
}
if ($driver = Arr::get($config, 'driver')) {
if (isset($this->extensions[$driver])) {
return $this->extensions[$driver]($config);
}
}
return $this->createConnection($config);
}
/**
* Get the configuration name.
*
* @return string
*/
abstract protected function getConfigName(): string;
/**
* Get the configuration for a connection.
*
* @param string|null $name
*
* @throws \InvalidArgumentException
*
* @return array
*/
public function getConnectionConfig(string $name = null): array
{
$name = $name ?: $this->getDefaultConnection();
return $this->getNamedConfig('connections', 'Connection', $name);
}
/**
* Get the given named configuration.
*
* @param string $type
* @param string $desc
* @param string $name
*
* @throws \InvalidArgumentException
*
* @return array
*/
protected function getNamedConfig(string $type, string $desc, string $name): array
{
$data = $this->config->get($this->getConfigName().'.'.$type);
if (!is_array($config = Arr::get($data, $name)) && !$config) {
throw new InvalidArgumentException("$desc [$name] not configured.");
}
$config['name'] = $name;
return $config;
}
/**
* Get the default connection name.
*
* @return string
*/
public function getDefaultConnection(): string
{
return $this->config->get($this->getConfigName().'.default');
}
/**
* Set the default connection name.
*
* @param string $name
*
* @return void
*/
public function setDefaultConnection(string $name): void
{
$this->config->set($this->getConfigName().'.default', $name);
}
/**
* Register an extension connection resolver.
*
* @param string $name
* @param callable $resolver
*
* @return void
*/
public function extend(string $name, callable $resolver): void
{
if ($resolver instanceof Closure) {
$this->extensions[$name] = $resolver->bindTo($this, $this);
} else {
$this->extensions[$name] = $resolver;
}
}
/**
* Return all of the created connections.
*
* @return array<string,object>
*/
public function getConnections(): array
{
return $this->connections;
}
/**
* Get the config instance.
*
* @return \Illuminate\Contracts\Config\Repository
*/
public function getConfig(): Repository
{
return $this->config;
}
/**
* Dynamically pass methods to the default connection.
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public function __call(string $method, array $parameters)
{
return $this->connection()->$method(...$parameters);
}
}
PK �8]�Hz� � "