decorate(function ($foo, $container) { * return new CachedFoo($foo, $container->get('cache')); * }) * * @param callable $callable The callable takes the decorated object as first parameter and * the container as second. * * @return FactoryDefinitionHelper */ function decorate($callable) { return new FactoryDefinitionHelper($callable, true); } } if (! function_exists('Cybot\Dependencies\DI\get')) { /** * Helper for referencing another container entry in an object definition. * * @param string $entryName * * @return EntryReference */ function get($entryName) { return new EntryReference($entryName); } } if (! function_exists('Cybot\Dependencies\DI\link')) { /** * Helper for referencing another container entry in an object definition. * * @deprecated \Cybot\Dependencies\DI\link() has been replaced by \Cybot\Dependencies\DI\get() * * @param string $entryName * * @return EntryReference */ function link($entryName) { return new EntryReference($entryName); } } if (! function_exists('Cybot\Dependencies\DI\env')) { /** * Helper for referencing environment variables. * * @param string $variableName The name of the environment variable. * @param mixed $defaultValue The default value to be used if the environment variable is not defined. * * @return EnvironmentVariableDefinitionHelper */ function env($variableName, $defaultValue = null) { // Only mark as optional if the default value was *explicitly* provided. $isOptional = 2 === func_num_args(); return new EnvironmentVariableDefinitionHelper($variableName, $isOptional, $defaultValue); } } if (! function_exists('Cybot\Dependencies\DI\add')) { /** * Helper for extending another definition. * * Example: * * 'log.backends' => Cybot\Dependencies\DI\add(Cybot\Dependencies\DI\get('My\Custom\LogBackend')) * * or: * * 'log.backends' => Cybot\Dependencies\DI\add([ * Cybot\Dependencies\DI\get('My\Custom\LogBackend') * ]) * * @param mixed|array $values A value or an array of values to add to the array. * * @return ArrayDefinitionExtensionHelper * * @since 5.0 */ function add($values) { if (! is_array($values)) { $values = [$values]; } return new ArrayDefinitionExtensionHelper($values); } } if (! function_exists('Cybot\Dependencies\DI\string')) { /** * Helper for concatenating strings. * * Example: * * 'log.filename' => Cybot\Dependencies\DI\string('{app.path}/app.log') * * @param string $expression A string expression. Use the `{}` placeholders to reference other container entries. * * @return StringDefinitionHelper * * @since 5.0 */ function string($expression) { return new StringDefinitionHelper((string) $expression); } }