__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
declare(strict_types=1);
namespace DI\Definition;
/**
* Defines a reference to an environment variable, with fallback to a default
* value if the environment variable is not defined.
*
* @author James Harris <james.harris@icecave.com.au>
*/
class EnvironmentVariableDefinition implements Definition
{
/** Entry name. */
private string $name = '';
/**
* @param string $variableName The name of the environment variable
* @param bool $isOptional Whether or not the environment variable definition is optional. If true and the environment variable given by $variableName has not been defined, $defaultValue is used.
* @param mixed $defaultValue The default value to use if the environment variable is optional and not provided
*/
public function __construct(
private string $variableName,
private bool $isOptional = false,
private mixed $defaultValue = null,
) {
}
public function getName() : string
{
return $this->name;
}
public function setName(string $name) : void
{
$this->name = $name;
}
/**
* @return string The name of the environment variable
*/
public function getVariableName() : string
{
return $this->variableName;
}
/**
* @return bool Whether or not the environment variable definition is optional
*/
public function isOptional() : bool
{
return $this->isOptional;
}
/**
* @return mixed The default value to use if the environment variable is optional and not provided
*/
public function getDefaultValue() : mixed
{
return $this->defaultValue;
}
public function replaceNestedDefinitions(callable $replacer) : void
{
$this->defaultValue = $replacer($this->defaultValue);
}
public function __toString() : string
{
$str = ' variable = ' . $this->variableName . \PHP_EOL
. ' optional = ' . ($this->isOptional ? 'yes' : 'no');
if ($this->isOptional) {
if ($this->defaultValue instanceof Definition) {
$nestedDefinition = (string) $this->defaultValue;
$defaultValueStr = str_replace(\PHP_EOL, \PHP_EOL . ' ', $nestedDefinition);
} else {
$defaultValueStr = var_export($this->defaultValue, true);
}
$str .= \PHP_EOL . ' default = ' . $defaultValueStr;
}
return sprintf('Environment variable (' . \PHP_EOL . '%s' . \PHP_EOL . ')', $str);
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Dumper | Folder | 0777 |
|
|
| Exception | Folder | 0777 |
|
|
| Helper | Folder | 0777 |
|
|
| ObjectDefinition | Folder | 0777 |
|
|
| Resolver | Folder | 0777 |
|
|
| Source | Folder | 0777 |
|
|
| ArrayDefinition.php | File | 1.31 KB | 0777 |
|
| ArrayDefinitionExtension.php | File | 1017 B | 0777 |
|
| AutowireDefinition.php | File | 170 B | 0777 |
|
| DecoratorDefinition.php | File | 782 B | 0777 |
|
| Definition.php | File | 847 B | 0777 |
|
| EnvironmentVariableDefinition.php | File | 2.5 KB | 0777 |
|
| ExtendsPreviousDefinition.php | File | 323 B | 0777 |
|
| FactoryDefinition.php | File | 1.72 KB | 0777 |
|
| InstanceDefinition.php | File | 1.12 KB | 0777 |
|
| ObjectDefinition.php | File | 6.29 KB | 0777 |
|
| Reference.php | File | 1.29 KB | 0777 |
|
| SelfResolvingDefinition.php | File | 528 B | 0777 |
|
| StringDefinition.php | File | 2.21 KB | 0777 |
|
| ValueDefinition.php | File | 1.11 KB | 0777 |
|