/var/www/html/wp-content/plugins/elementor/vendor_prefixed/php-di/php-di/src/functions.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php

declare (strict_types=1);
namespace 
ElementorDeps\DI;

use 
ElementorDeps\DI\Definition\ArrayDefinitionExtension;
use 
ElementorDeps\DI\Definition\EnvironmentVariableDefinition;
use 
ElementorDeps\DI\Definition\Helper\AutowireDefinitionHelper;
use 
ElementorDeps\DI\Definition\Helper\CreateDefinitionHelper;
use 
ElementorDeps\DI\Definition\Helper\FactoryDefinitionHelper;
use 
ElementorDeps\DI\Definition\Reference;
use 
ElementorDeps\DI\Definition\StringDefinition;
use 
ElementorDeps\DI\Definition\ValueDefinition;
if (!
\function_exists('ElementorDeps\\DI\\value')) {
    
/**
     * Helper for defining a value.
     *
     * @param mixed $value
     */
    
function value($value) : ValueDefinition
    
{
        return new 
ValueDefinition($value);
    }
}
if (!
\function_exists('ElementorDeps\\DI\\create')) {
    
/**
     * Helper for defining an object.
     *
     * @param string|null $className Class name of the object.
     *                               If null, the name of the entry (in the container) will be used as class name.
     */
    
function create(string $className null) : CreateDefinitionHelper
    
{
        return new 
CreateDefinitionHelper($className);
    }
}
if (!
\function_exists('ElementorDeps\\DI\\autowire')) {
    
/**
     * Helper for autowiring an object.
     *
     * @param string|null $className Class name of the object.
     *                               If null, the name of the entry (in the container) will be used as class name.
     */
    
function autowire(string $className null) : AutowireDefinitionHelper
    
{
        return new 
AutowireDefinitionHelper($className);
    }
}
if (!
\function_exists('ElementorDeps\\DI\\factory')) {
    
/**
     * Helper for defining a container entry using a factory function/callable.
     *
     * @param callable $factory The factory is a callable that takes the container as parameter
     *                          and returns the value to register in the container.
     */
    
function factory($factory) : FactoryDefinitionHelper
    
{
        return new 
FactoryDefinitionHelper($factory);
    }
}
if (!
\function_exists('ElementorDeps\\DI\\decorate')) {
    
/**
     * Decorate the previous definition using a callable.
     *
     * Example:
     *
     *     'foo' => 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.
     */
    
function decorate($callable) : FactoryDefinitionHelper
    
{
        return new 
FactoryDefinitionHelper($callable\true);
    }
}
if (!
\function_exists('ElementorDeps\\DI\\get')) {
    
/**
     * Helper for referencing another container entry in an object definition.
     */
    
function get(string $entryName) : Reference
    
{
        return new 
Reference($entryName);
    }
}
if (!
\function_exists('ElementorDeps\\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.
     */
    
function env(string $variableName$defaultValue null) : EnvironmentVariableDefinition
    
{
        
// Only mark as optional if the default value was *explicitly* provided.
        
$isOptional === \func_num_args();
        return new 
EnvironmentVariableDefinition($variableName$isOptional$defaultValue);
    }
}
if (!
\function_exists('ElementorDeps\\DI\\add')) {
    
/**
     * Helper for extending another definition.
     *
     * Example:
     *
     *     'log.backends' => DI\add(DI\get('My\Custom\LogBackend'))
     *
     * or:
     *
     *     'log.backends' => DI\add([
     *         DI\get('My\Custom\LogBackend')
     *     ])
     *
     * @param mixed|array $values A value or an array of values to add to the array.
     *
     * @since 5.0
     */
    
function add($values) : ArrayDefinitionExtension
    
{
        if (!
\is_array($values)) {
            
$values = [$values];
        }
        return new 
ArrayDefinitionExtension($values);
    }
}
if (!
\function_exists('ElementorDeps\\DI\\string')) {
    
/**
     * Helper for concatenating strings.
     *
     * Example:
     *
     *     'log.filename' => DI\string('{app.path}/app.log')
     *
     * @param string $expression A string expression. Use the `{}` placeholders to reference other container entries.
     *
     * @since 5.0
     */
    
function string(string $expression) : StringDefinition
    
{
        return new 
StringDefinition($expression);
    }
}