Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1d008f7

Browse filesBrowse files
committed
Allow calling custom processors directly on EnvConfigurator
Add magic __call method to EnvConfigurator to allow calling custom processors as methods instead of using the custom method.
1 parent 8451a9f commit 1d008f7
Copy full SHA for 1d008f7

File tree

Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/EnvConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/EnvConfigurator.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ public function __toString()
3131
return '%env('.implode(':', $this->stack).')%';
3232
}
3333

34+
/**
35+
* @return $this
36+
*/
37+
public function __call(string $name, array $arguments): self
38+
{
39+
$processor = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $name));
40+
41+
$this->custom($processor, ...$arguments);
42+
43+
return $this;
44+
}
45+
3446
/**
3547
* @return $this
3648
*/

‎src/Symfony/Component/DependencyInjection/Tests/Loader/Configurator/EnvConfiguratorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Loader/Configurator/EnvConfiguratorTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ public function provide()
3131
yield ['%env(string:FOO)%', (new EnvConfigurator('FOO'))->string()];
3232
yield ['%env(key:path:url:FOO)%', (new EnvConfigurator('FOO'))->url()->key('path')];
3333
yield ['%env(default:fallback:bar:arg1:FOO)%', (new EnvConfigurator('FOO'))->custom('bar', 'arg1')->default('fallback')];
34+
yield ['%env(my_processor:my_argument:FOO)%', (new EnvConfigurator('FOO'))->myProcessor('my_argument')];
3435
}
3536
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.