|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\DependencyInjection\Loader\Configurator; |
| 13 | + |
| 14 | +class EnvConfigurator |
| 15 | +{ |
| 16 | + /** |
| 17 | + * @var string[] |
| 18 | + */ |
| 19 | + private $stack; |
| 20 | + |
| 21 | + public function __construct(string $name) |
| 22 | + { |
| 23 | + $this->stack = explode(':', $name); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * @return string |
| 28 | + */ |
| 29 | + public function __toString() |
| 30 | + { |
| 31 | + return '%env('.implode(':', $this->stack).')%'; |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * @return $this |
| 36 | + */ |
| 37 | + public function custom(string $processor, ...$args): self |
| 38 | + { |
| 39 | + array_unshift($this->stack, $processor, ...$args); |
| 40 | + |
| 41 | + return $this; |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * @return $this |
| 46 | + */ |
| 47 | + public function base64(): self |
| 48 | + { |
| 49 | + array_unshift($this->stack, 'base64'); |
| 50 | + |
| 51 | + return $this; |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * @return $this |
| 56 | + */ |
| 57 | + public function bool(): self |
| 58 | + { |
| 59 | + array_unshift($this->stack, 'bool'); |
| 60 | + |
| 61 | + return $this; |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * @return $this |
| 66 | + */ |
| 67 | + public function not(): self |
| 68 | + { |
| 69 | + array_unshift($this->stack, 'not'); |
| 70 | + |
| 71 | + return $this; |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * @return $this |
| 76 | + */ |
| 77 | + public function const(): self |
| 78 | + { |
| 79 | + array_unshift($this->stack, 'const'); |
| 80 | + |
| 81 | + return $this; |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * @return $this |
| 86 | + */ |
| 87 | + public function csv(): self |
| 88 | + { |
| 89 | + array_unshift($this->stack, 'csv'); |
| 90 | + |
| 91 | + return $this; |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * @return $this |
| 96 | + */ |
| 97 | + public function file(): self |
| 98 | + { |
| 99 | + array_unshift($this->stack, 'file'); |
| 100 | + |
| 101 | + return $this; |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * @return $this |
| 106 | + */ |
| 107 | + public function float(): self |
| 108 | + { |
| 109 | + array_unshift($this->stack, 'float'); |
| 110 | + |
| 111 | + return $this; |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * @return $this |
| 116 | + */ |
| 117 | + public function int(): self |
| 118 | + { |
| 119 | + array_unshift($this->stack, 'int'); |
| 120 | + |
| 121 | + return $this; |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * @return $this |
| 126 | + */ |
| 127 | + public function json(): self |
| 128 | + { |
| 129 | + array_unshift($this->stack, 'json'); |
| 130 | + |
| 131 | + return $this; |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * @return $this |
| 136 | + */ |
| 137 | + public function key(string $key): self |
| 138 | + { |
| 139 | + array_unshift($this->stack, 'key', $key); |
| 140 | + |
| 141 | + return $this; |
| 142 | + } |
| 143 | + |
| 144 | + /** |
| 145 | + * @return $this |
| 146 | + */ |
| 147 | + public function url(): self |
| 148 | + { |
| 149 | + array_unshift($this->stack, 'url'); |
| 150 | + |
| 151 | + return $this; |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * @return $this |
| 156 | + */ |
| 157 | + public function queryString(): self |
| 158 | + { |
| 159 | + array_unshift($this->stack, 'query_string'); |
| 160 | + |
| 161 | + return $this; |
| 162 | + } |
| 163 | + |
| 164 | + /** |
| 165 | + * @return $this |
| 166 | + */ |
| 167 | + public function resolve(): self |
| 168 | + { |
| 169 | + array_unshift($this->stack, 'resolve'); |
| 170 | + |
| 171 | + return $this; |
| 172 | + } |
| 173 | + |
| 174 | + /** |
| 175 | + * @return $this |
| 176 | + */ |
| 177 | + public function default(string $fallbackParam): self |
| 178 | + { |
| 179 | + array_unshift($this->stack, 'default', $fallbackParam); |
| 180 | + |
| 181 | + return $this; |
| 182 | + } |
| 183 | + |
| 184 | + /** |
| 185 | + * @return $this |
| 186 | + */ |
| 187 | + public function string(): self |
| 188 | + { |
| 189 | + array_unshift($this->stack, 'string'); |
| 190 | + |
| 191 | + return $this; |
| 192 | + } |
| 193 | + |
| 194 | + /** |
| 195 | + * @return $this |
| 196 | + */ |
| 197 | + public function trim(): self |
| 198 | + { |
| 199 | + array_unshift($this->stack, 'trim'); |
| 200 | + |
| 201 | + return $this; |
| 202 | + } |
| 203 | + |
| 204 | + /** |
| 205 | + * @return $this |
| 206 | + */ |
| 207 | + public function require(): self |
| 208 | + { |
| 209 | + array_unshift($this->stack, 'require'); |
| 210 | + |
| 211 | + return $this; |
| 212 | + } |
| 213 | +} |
0 commit comments