/var/www/html_us/wp-content/plugins/wp-smtp/vendor/lucatume/di52/src/Builders/ClosureBuilder.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
<?php
/**
 * Closure-based builder.
 *
 * @package lucatume\DI52
 */

namespace lucatume\DI52\Builders;

use 
Closure;
use 
lucatume\DI52\Container;

/**
 * Class ClosureBuilder
 *
 * @package lucatume\DI52\Builders
 */
class ClosureBuilder implements BuilderInterface
{
    
/**
     * A reference to the resolver currently using the builder.
     *
     * @var Container
     */
    
protected $container;

    
/**
     * A reference to the closure the builder should run to build.
     *
     * @var Closure
     */
    
protected $closure;

    
/**
     * ClosureBuilder constructor.
     *
     * @param Container $container A reference to the current DI container instance.
     * @param Closure   $closure   A reference to the closure that should be used to build the implementation.
     */
    
public function __construct(Container $containerClosure $closure)
    {
        
$this->container $container;
        
$this->closure $closure;
    }

    
/**
     * Calls the Closure handled by the builder to return the built implementation.
     *
     * @return mixed The built implementation.
     */
    
public function build()
    {
        
$closure $this->closure;
        return 
$closure($this->container);
    }
}