composeer update
This commit is contained in:
2
vendor/vlucas/phpdotenv/composer.json
vendored
2
vendor/vlucas/phpdotenv/composer.json
vendored
@@ -25,7 +25,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.3-dev"
|
||||
"dev-master": "3.4-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Dotenv\Environment;
|
||||
|
||||
use Dotenv\Environment\Adapter\ArrayAdapter;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* This is the abstract variables implementation.
|
||||
*
|
||||
@@ -16,6 +19,13 @@ abstract class AbstractVariables implements VariablesInterface
|
||||
*/
|
||||
private $immutable;
|
||||
|
||||
/**
|
||||
* The record of loaded variables.
|
||||
*
|
||||
* @var \Dotenv\Environment\Adapter\ArrayAdapter
|
||||
*/
|
||||
private $loaded;
|
||||
|
||||
/**
|
||||
* Create a new environment variables instance.
|
||||
*
|
||||
@@ -26,8 +36,104 @@ abstract class AbstractVariables implements VariablesInterface
|
||||
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)) {
|
||||
throw new InvalidArgumentException('Expected name to be a string.');
|
||||
}
|
||||
|
||||
return $this->getInternal($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an environment variable.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected abstract 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)) {
|
||||
throw new InvalidArgumentException('Expected name to be a string.');
|
||||
}
|
||||
|
||||
// Don't overwrite existing environment variables if we're immutable
|
||||
// Ruby's dotenv does this with `ENV[key] ||= value`.
|
||||
if ($this->isImmutable() && $this->get($name) !== null && $this->loaded->get($name)->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setInternal($name, $value);
|
||||
$this->loaded->set($name, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an environment variable.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected abstract function setInternal($name, $value = null);
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear($name)
|
||||
{
|
||||
if (!is_string($name)) {
|
||||
throw new InvalidArgumentException('Expected name to be a string.');
|
||||
}
|
||||
|
||||
// Don't clear anything if we're immutable.
|
||||
if ($this->isImmutable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->clearInternal($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear an environment variable.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected abstract function clearInternal($name);
|
||||
|
||||
/**
|
||||
* Determine if the environment is immutable.
|
||||
*
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Dotenv\Environment;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* The default implementation of the environment variables interface.
|
||||
*/
|
||||
@@ -37,16 +35,10 @@ class DotenvVariables extends AbstractVariables
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function get($name)
|
||||
protected function getInternal($name)
|
||||
{
|
||||
if (!is_string($name)) {
|
||||
throw new InvalidArgumentException('Expected name to be a string.');
|
||||
}
|
||||
|
||||
foreach ($this->adapters as $adapter) {
|
||||
$result = $adapter->get($name);
|
||||
if ($result->isDefined()) {
|
||||
@@ -61,22 +53,10 @@ class DotenvVariables extends AbstractVariables
|
||||
* @param string $name
|
||||
* @param string|null $value
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($name, $value = null)
|
||||
protected function setInternal($name, $value = null)
|
||||
{
|
||||
if (!is_string($name)) {
|
||||
throw new InvalidArgumentException('Expected name to be a string.');
|
||||
}
|
||||
|
||||
// Don't overwrite existing environment variables if we're immutable
|
||||
// Ruby's dotenv does this with `ENV[key] ||= value`.
|
||||
if ($this->isImmutable() && $this->get($name) !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->adapters as $adapter) {
|
||||
$adapter->set($name, $value);
|
||||
}
|
||||
@@ -87,21 +67,10 @@ class DotenvVariables extends AbstractVariables
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear($name)
|
||||
protected function clearInternal($name)
|
||||
{
|
||||
if (!is_string($name)) {
|
||||
throw new InvalidArgumentException('Expected name to be a string.');
|
||||
}
|
||||
|
||||
// Don't clear anything if we're immutable.
|
||||
if ($this->isImmutable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->adapters as $adapter) {
|
||||
$adapter->clear($name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user