Passed
Push — main ( 795029...4944ea )
by Michael
03:13
created

enableMethodForwarding()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
use MichaelRubel\EnhancedContainer\Call;
6
use MichaelRubel\EnhancedContainer\Core\BindingBuilder;
7
8
if (! function_exists('call')) {
9
    /**
10
     * @param string|object $class
11
     * @param array         $parameters
12
     *
13
     * @return mixed
14
     */
15
    function call(string|object $class, array $parameters = []): mixed
16
    {
17
        return app(Call::class, [$class, $parameters]);
18
    }
19
}
20
21
if (! function_exists('bind')) {
22
    /**
23
     * @param string|object $abstract
24
     *
25
     * @return BindingBuilder
26
     */
27
    function bind(string|object $abstract): BindingBuilder
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
28
    {
29
        return new BindingBuilder($abstract);
30
    }
31
}
32
33
if (! function_exists('singleton')) {
34
    /**
35
     * @param string              $abstract
36
     * @param Closure|string|null $concrete
37
     *
38
     * @return void
39
     */
40
    function singleton(string $abstract, \Closure|string $concrete = null): void
41
    {
42
        app()->singleton($abstract, $concrete);
43
    }
44
}
45
46
if (! function_exists('scoped')) {
47
    /**
48
     * @param string              $abstract
49
     * @param Closure|string|null $concrete
50
     *
51
     * @return void
52
     */
53
    function scoped(string $abstract, \Closure|string $concrete = null): void
54
    {
55
        app()->scoped($abstract, $concrete);
56
    }
57
}
58
59
if (! function_exists('extend')) {
60
    /**
61
     * @param string  $abstract
62
     * @param Closure $closure
63
     *
64
     * @return void
65
     */
66
    function extend(string $abstract, \Closure $closure): void
67
    {
68
        app()->extend($abstract, $closure);
69
    }
70
}
71
72
if (! function_exists('enableMethodForwarding')) {
73
    /**
74
     * @return void
75
     */
76
    function enableMethodForwarding(): void
77
    {
78
        config(['enhanced-container.forwarding_enabled' => true]);
79
    }
80
}
81
82
if (! function_exists('disableMethodForwarding')) {
83
    /**
84
     * @return void
85
     */
86
    function disableMethodForwarding(): void
87
    {
88
        config(['enhanced-container.forwarding_enabled' => false]);
89
    }
90
}
91