upgraded dependencies
This commit is contained in:
180
vendor/vlucas/phpdotenv/src/Repository/AbstractRepository.php
vendored
Normal file
180
vendor/vlucas/phpdotenv/src/Repository/AbstractRepository.php
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository;
|
||||
|
||||
use Dotenv\Repository\Adapter\ArrayAdapter;
|
||||
use InvalidArgumentException;
|
||||
use ReturnTypeWillChange;
|
||||
|
||||
abstract class AbstractRepository implements RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Are we immutable?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $immutable;
|
||||
|
||||
/**
|
||||
* The record of loaded variables.
|
||||
*
|
||||
* @var \Dotenv\Repository\Adapter\ArrayAdapter
|
||||
*/
|
||||
private $loaded;
|
||||
|
||||
/**
|
||||
* Create a new repository instance.
|
||||
*
|
||||
* @param bool $immutable
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($immutable)
|
||||
{
|
||||
$this->immutable = $immutable;
|
||||
$this->loaded = new ArrayAdapter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an environment variable.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
if (!is_string($name) || '' === $name) {
|
||||
throw new InvalidArgumentException('Expected name to be a non-empty string.');
|
||||
}
|
||||
|
||||
return $this->getInternal($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
abstract protected function getInternal($name);
|
||||
|
||||
/**
|
||||
* Set an environment variable.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($name, $value = null)
|
||||
{
|
||||
if (!is_string($name) || '' === $name) {
|
||||
throw new InvalidArgumentException('Expected name to be a non-empty string.');
|
||||
}
|
||||
|
||||
// Don't overwrite existing environment variables if we're immutable
|
||||
// Ruby's dotenv does this with `ENV[key] ||= value`.
|
||||
if ($this->immutable && $this->get($name) !== null && $this->loaded->get($name)->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setInternal($name, $value);
|
||||
$this->loaded->set($name, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function setInternal($name, $value = null);
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear($name)
|
||||
{
|
||||
if (!is_string($name) || '' === $name) {
|
||||
throw new InvalidArgumentException('Expected name to be a non-empty string.');
|
||||
}
|
||||
|
||||
// Don't clear anything if we're immutable.
|
||||
if ($this->immutable) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->clearInternal($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function clearInternal($name);
|
||||
|
||||
/**
|
||||
* Tells whether environment variable has been defined.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($name)
|
||||
{
|
||||
return is_string($name) && $name !== '' && $this->get($name) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return $this->has($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->get($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
$this->set($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
$this->clear($offset);
|
||||
}
|
||||
}
|
||||
66
vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php
vendored
Normal file
66
vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository\Adapter;
|
||||
|
||||
use PhpOption\None;
|
||||
|
||||
class ApacheAdapter implements AvailabilityInterface, ReaderInterface, WriterInterface
|
||||
{
|
||||
/**
|
||||
* Determines if the adapter is supported.
|
||||
*
|
||||
* This happens if PHP is running as an Apache module.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSupported()
|
||||
{
|
||||
return function_exists('apache_getenv') && function_exists('apache_setenv');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an environment variable, if it exists.
|
||||
*
|
||||
* This is intentionally not implemented, since this adapter exists only as
|
||||
* a means to overwrite existing apache environment variables.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return \PhpOption\Option<string|null>
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
return None::create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an environment variable.
|
||||
*
|
||||
* Only if an existing apache variable exists do we overwrite it.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($name, $value = null)
|
||||
{
|
||||
if (apache_getenv($name) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
apache_setenv($name, (string) $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear($name)
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
}
|
||||
67
vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php
vendored
Normal file
67
vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository\Adapter;
|
||||
|
||||
use PhpOption\None;
|
||||
use PhpOption\Some;
|
||||
|
||||
class ArrayAdapter implements AvailabilityInterface, ReaderInterface, WriterInterface
|
||||
{
|
||||
/**
|
||||
* The variables and their values.
|
||||
*
|
||||
* @var array<non-empty-string,string|null>
|
||||
*/
|
||||
private $variables = [];
|
||||
|
||||
/**
|
||||
* Determines if the adapter is supported.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an environment variable, if it exists.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return \PhpOption\Option<string|null>
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
if (!array_key_exists($name, $this->variables)) {
|
||||
return None::create();
|
||||
}
|
||||
|
||||
return Some::create($this->variables[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($name, $value = null)
|
||||
{
|
||||
$this->variables[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear($name)
|
||||
{
|
||||
unset($this->variables[$name]);
|
||||
}
|
||||
}
|
||||
13
vendor/vlucas/phpdotenv/src/Repository/Adapter/AvailabilityInterface.php
vendored
Normal file
13
vendor/vlucas/phpdotenv/src/Repository/Adapter/AvailabilityInterface.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository\Adapter;
|
||||
|
||||
interface AvailabilityInterface
|
||||
{
|
||||
/**
|
||||
* Determines if the adapter is supported.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSupported();
|
||||
}
|
||||
72
vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php
vendored
Normal file
72
vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository\Adapter;
|
||||
|
||||
use PhpOption\None;
|
||||
use PhpOption\Some;
|
||||
|
||||
class EnvConstAdapter implements AvailabilityInterface, ReaderInterface, WriterInterface
|
||||
{
|
||||
/**
|
||||
* Determines if the adapter is supported.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an environment variable, if it exists.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return \PhpOption\Option<string|null>
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
if (!array_key_exists($name, $_ENV)) {
|
||||
return None::create();
|
||||
}
|
||||
|
||||
$value = $_ENV[$name];
|
||||
|
||||
if (is_scalar($value)) {
|
||||
/** @var \PhpOption\Option<string|null> */
|
||||
return Some::create((string) $value);
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
/** @var \PhpOption\Option<string|null> */
|
||||
return Some::create(null);
|
||||
}
|
||||
|
||||
return None::create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($name, $value = null)
|
||||
{
|
||||
$_ENV[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear($name)
|
||||
{
|
||||
unset($_ENV[$name]);
|
||||
}
|
||||
}
|
||||
56
vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php
vendored
Normal file
56
vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository\Adapter;
|
||||
|
||||
use PhpOption\Option;
|
||||
|
||||
class PutenvAdapter implements AvailabilityInterface, ReaderInterface, WriterInterface
|
||||
{
|
||||
/**
|
||||
* Determines if the adapter is supported.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSupported()
|
||||
{
|
||||
return function_exists('getenv') && function_exists('putenv');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an environment variable, if it exists.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return \PhpOption\Option<string|null>
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
/** @var \PhpOption\Option<string|null> */
|
||||
return Option::fromValue(getenv($name), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($name, $value = null)
|
||||
{
|
||||
putenv("$name=$value");
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear($name)
|
||||
{
|
||||
putenv($name);
|
||||
}
|
||||
}
|
||||
15
vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php
vendored
Normal file
15
vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository\Adapter;
|
||||
|
||||
interface ReaderInterface extends AvailabilityInterface
|
||||
{
|
||||
/**
|
||||
* Get an environment variable, if it exists.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return \PhpOption\Option<string|null>
|
||||
*/
|
||||
public function get($name);
|
||||
}
|
||||
72
vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php
vendored
Normal file
72
vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository\Adapter;
|
||||
|
||||
use PhpOption\None;
|
||||
use PhpOption\Some;
|
||||
|
||||
class ServerConstAdapter implements AvailabilityInterface, ReaderInterface, WriterInterface
|
||||
{
|
||||
/**
|
||||
* Determines if the adapter is supported.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an environment variable, if it exists.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return \PhpOption\Option<string|null>
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
if (!array_key_exists($name, $_SERVER)) {
|
||||
return None::create();
|
||||
}
|
||||
|
||||
$value = $_SERVER[$name];
|
||||
|
||||
if (is_scalar($value)) {
|
||||
/** @var \PhpOption\Option<string|null> */
|
||||
return Some::create((string) $value);
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
/** @var \PhpOption\Option<string|null> */
|
||||
return Some::create(null);
|
||||
}
|
||||
|
||||
return None::create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($name, $value = null)
|
||||
{
|
||||
$_SERVER[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear($name)
|
||||
{
|
||||
unset($_SERVER[$name]);
|
||||
}
|
||||
}
|
||||
25
vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php
vendored
Normal file
25
vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository\Adapter;
|
||||
|
||||
interface WriterInterface extends AvailabilityInterface
|
||||
{
|
||||
/**
|
||||
* Set an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($name, $value = null);
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear($name);
|
||||
}
|
||||
86
vendor/vlucas/phpdotenv/src/Repository/AdapterRepository.php
vendored
Normal file
86
vendor/vlucas/phpdotenv/src/Repository/AdapterRepository.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository;
|
||||
|
||||
class AdapterRepository extends AbstractRepository
|
||||
{
|
||||
/**
|
||||
* The set of readers to use.
|
||||
*
|
||||
* @var \Dotenv\Repository\Adapter\ReaderInterface[]
|
||||
*/
|
||||
protected $readers;
|
||||
|
||||
/**
|
||||
* The set of writers to use.
|
||||
*
|
||||
* @var \Dotenv\Repository\Adapter\WriterInterface[]
|
||||
*/
|
||||
protected $writers;
|
||||
|
||||
/**
|
||||
* Create a new adapter repository instance.
|
||||
*
|
||||
* @param \Dotenv\Repository\Adapter\ReaderInterface[] $readers
|
||||
* @param \Dotenv\Repository\Adapter\WriterInterface[] $writers
|
||||
* @param bool $immutable
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $readers, array $writers, $immutable)
|
||||
{
|
||||
$this->readers = $readers;
|
||||
$this->writers = $writers;
|
||||
parent::__construct($immutable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an environment variable.
|
||||
*
|
||||
* We do this by querying our readers sequentially.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getInternal($name)
|
||||
{
|
||||
foreach ($this->readers as $reader) {
|
||||
$result = $reader->get($name);
|
||||
if ($result->isDefined()) {
|
||||
return $result->get();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setInternal($name, $value = null)
|
||||
{
|
||||
foreach ($this->writers as $writers) {
|
||||
$writers->set($name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function clearInternal($name)
|
||||
{
|
||||
foreach ($this->writers as $writers) {
|
||||
$writers->clear($name);
|
||||
}
|
||||
}
|
||||
}
|
||||
144
vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php
vendored
Normal file
144
vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository;
|
||||
|
||||
use Dotenv\Repository\Adapter\ApacheAdapter;
|
||||
use Dotenv\Repository\Adapter\AvailabilityInterface;
|
||||
use Dotenv\Repository\Adapter\EnvConstAdapter;
|
||||
use Dotenv\Repository\Adapter\PutenvAdapter;
|
||||
use Dotenv\Repository\Adapter\ServerConstAdapter;
|
||||
|
||||
class RepositoryBuilder
|
||||
{
|
||||
/**
|
||||
* The set of readers to use.
|
||||
*
|
||||
* @var \Dotenv\Repository\Adapter\ReaderInterface[]|null
|
||||
*/
|
||||
private $readers;
|
||||
|
||||
/**
|
||||
* The set of writers to use.
|
||||
*
|
||||
* @var \Dotenv\Repository\Adapter\WriterInterface[]|null
|
||||
*/
|
||||
private $writers;
|
||||
|
||||
/**
|
||||
* Are we immutable?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $immutable;
|
||||
|
||||
/**
|
||||
* Create a new repository builder instance.
|
||||
*
|
||||
* @param \Dotenv\Repository\Adapter\ReaderInterface[]|null $readers
|
||||
* @param \Dotenv\Repository\Adapter\WriterInterface[]|null $writers
|
||||
* @param bool $immutable
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function __construct(array $readers = null, array $writers = null, $immutable = false)
|
||||
{
|
||||
$this->readers = $readers;
|
||||
$this->writers = $writers;
|
||||
$this->immutable = $immutable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new repository builder instance.
|
||||
*
|
||||
* @return \Dotenv\Repository\RepositoryBuilder
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a repository builder with the given readers.
|
||||
*
|
||||
* @param \Dotenv\Repository\Adapter\ReaderInterface[]|null $readers
|
||||
*
|
||||
* @return \Dotenv\Repository\RepositoryBuilder
|
||||
*/
|
||||
public function withReaders(array $readers = null)
|
||||
{
|
||||
$readers = $readers === null ? null : self::filterByAvailability($readers);
|
||||
|
||||
return new self($readers, $this->writers, $this->immutable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a repository builder with the given writers.
|
||||
*
|
||||
* @param \Dotenv\Repository\Adapter\WriterInterface[]|null $writers
|
||||
*
|
||||
* @return \Dotenv\Repository\RepositoryBuilder
|
||||
*/
|
||||
public function withWriters(array $writers = null)
|
||||
{
|
||||
$writers = $writers === null ? null : self::filterByAvailability($writers);
|
||||
|
||||
return new self($this->readers, $writers, $this->immutable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a repository builder with mutability enabled.
|
||||
*
|
||||
* @return \Dotenv\Repository\RepositoryBuilder
|
||||
*/
|
||||
public function immutable()
|
||||
{
|
||||
return new self($this->readers, $this->writers, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new repository instance.
|
||||
*
|
||||
* @return \Dotenv\Repository\RepositoryInterface
|
||||
*/
|
||||
public function make()
|
||||
{
|
||||
if ($this->readers === null || $this->writers === null) {
|
||||
$defaults = self::defaultAdapters();
|
||||
}
|
||||
|
||||
return new AdapterRepository(
|
||||
$this->readers === null ? $defaults : $this->readers,
|
||||
$this->writers === null ? $defaults : $this->writers,
|
||||
$this->immutable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the array of default adapters.
|
||||
*
|
||||
* @return \Dotenv\Repository\Adapter\AvailabilityInterface[]
|
||||
*/
|
||||
private static function defaultAdapters()
|
||||
{
|
||||
return self::filterByAvailability([
|
||||
new ApacheAdapter(),
|
||||
new EnvConstAdapter(),
|
||||
new ServerConstAdapter(),
|
||||
new PutenvAdapter(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter an array of adapters to only those that are supported.
|
||||
*
|
||||
* @param \Dotenv\Repository\Adapter\AvailabilityInterface[] $adapters
|
||||
*
|
||||
* @return \Dotenv\Repository\Adapter\AvailabilityInterface[]
|
||||
*/
|
||||
private static function filterByAvailability(array $adapters)
|
||||
{
|
||||
return array_filter($adapters, function (AvailabilityInterface $adapter) {
|
||||
return $adapter->isSupported();
|
||||
});
|
||||
}
|
||||
}
|
||||
54
vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php
vendored
Normal file
54
vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Dotenv\Repository;
|
||||
|
||||
use ArrayAccess;
|
||||
|
||||
/**
|
||||
* @extends \ArrayAccess<string,string|null>
|
||||
*/
|
||||
interface RepositoryInterface extends ArrayAccess
|
||||
{
|
||||
/**
|
||||
* Tells whether environment variable has been defined.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($name);
|
||||
|
||||
/**
|
||||
* Get an environment variable.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function get($name);
|
||||
|
||||
/**
|
||||
* Set an environment variable.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($name, $value = null);
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear($name);
|
||||
}
|
||||
Reference in New Issue
Block a user