upgrade to laravel 7 and set branch to v2

This commit is contained in:
2020-12-25 11:22:15 +00:00
parent 516105c492
commit 0ddd298350
4638 changed files with 132501 additions and 190226 deletions
@@ -0,0 +1,64 @@
<?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 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 string $name
* @param string|null $value
*
* @return void
*/
public function set($name, $value = null)
{
if (apache_getenv($name) !== false) {
apache_setenv($name, (string) $value);
}
}
/**
* Clear an environment variable.
*
* @param string $name
*
* @return void
*/
public function clear($name)
{
// Nothing to do here.
}
}
@@ -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<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 string $name
*
* @return \PhpOption\Option<string|null>
*/
public function get($name)
{
if (array_key_exists($name, $this->variables)) {
return Some::create($this->variables[$name]);
}
return None::create();
}
/**
* Set an environment variable.
*
* @param string $name
* @param string|null $value
*
* @return void
*/
public function set($name, $value = null)
{
$this->variables[$name] = $value;
}
/**
* Clear an environment variable.
*
* @param string $name
*
* @return void
*/
public function clear($name)
{
unset($this->variables[$name]);
}
}
@@ -0,0 +1,13 @@
<?php
namespace Dotenv\Repository\Adapter;
interface AvailabilityInterface
{
/**
* Determines if the adapter is supported.
*
* @return bool
*/
public function isSupported();
}
@@ -0,0 +1,60 @@
<?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 string $name
*
* @return \PhpOption\Option<string|null>
*/
public function get($name)
{
if (array_key_exists($name, $_ENV)) {
return Some::create($_ENV[$name]);
}
return None::create();
}
/**
* Set an environment variable.
*
* @param string $name
* @param string|null $value
*
* @return void
*/
public function set($name, $value = null)
{
$_ENV[$name] = $value;
}
/**
* Clear an environment variable.
*
* @param string $name
*
* @return void
*/
public function clear($name)
{
unset($_ENV[$name]);
}
}
@@ -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 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 string $name
* @param string|null $value
*
* @return void
*/
public function set($name, $value = null)
{
putenv("$name=$value");
}
/**
* Clear an environment variable.
*
* @param string $name
*
* @return void
*/
public function clear($name)
{
putenv($name);
}
}
@@ -0,0 +1,15 @@
<?php
namespace Dotenv\Repository\Adapter;
interface ReaderInterface extends AvailabilityInterface
{
/**
* Get an environment variable, if it exists.
*
* @param string $name
*
* @return \PhpOption\Option<string|null>
*/
public function get($name);
}
@@ -0,0 +1,60 @@
<?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 string $name
*
* @return \PhpOption\Option<string|null>
*/
public function get($name)
{
if (array_key_exists($name, $_SERVER)) {
return Some::create($_SERVER[$name]);
}
return None::create();
}
/**
* Set an environment variable.
*
* @param string $name
* @param string|null $value
*
* @return void
*/
public function set($name, $value = null)
{
$_SERVER[$name] = $value;
}
/**
* Clear an environment variable.
*
* @param string $name
*
* @return void
*/
public function clear($name)
{
unset($_SERVER[$name]);
}
}
@@ -0,0 +1,25 @@
<?php
namespace Dotenv\Repository\Adapter;
interface WriterInterface extends AvailabilityInterface
{
/**
* Set an environment variable.
*
* @param string $name
* @param string|null $value
*
* @return void
*/
public function set($name, $value = null);
/**
* Clear an environment variable.
*
* @param string $name
*
* @return void
*/
public function clear($name);
}