Passed
Pull Request — main (#4)
by Michael
03:17
created

enableMethodForwarding()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
ccs 1
cts 1
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
use MichaelRubel\EnhancedContainer\Core\BindingBuilder;
6
use MichaelRubel\EnhancedContainer\Core\CallProxy;
7
8
if (! function_exists('call')) {
9
    /**
10
     * @param  string|object  $class
11
     * @param  array  $parameters
12
     * @param  string|null  $context
13
     *
14
     * @return CallProxy
15
     */
16
    function call(string|object $class, array $parameters = [], ?string $context = null): CallProxy
17
    {
18 64
        return app(CallProxy::class, [
19
            'class'        => $class,
20
            'dependencies' => $parameters,
21
            'context'      => $context,
22
        ]);
23
    }
24
}
25
26
if (! function_exists('bind')) {
27
    /**
28
     * @param  string|object  $abstract
29
     *
30
     * @return BindingBuilder
31
     */
32
    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...
33
    {
34 37
        return app(BindingBuilder::class, ['abstract' => $abstract]);
35
    }
36
}
37
38
if (! function_exists('singleton')) {
39
    /**
40
     * @param  string  $abstract
41
     * @param  Closure|string|null  $concrete
42
     *
43
     * @return void
44
     */
45
    function singleton(string $abstract, Closure|string $concrete = null): void
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...
46
    {
47 1
        app()->singleton($abstract, $concrete);
48
    }
49
}
50
51
if (! function_exists('scoped')) {
52
    /**
53
     * @param  string  $abstract
54
     * @param  Closure|string|null  $concrete
55
     *
56
     * @return void
57
     */
58
    function scoped(string $abstract, Closure|string $concrete = null): void
59
    {
60 1
        app()->scoped($abstract, $concrete);
61
    }
62
}
63
64
if (! function_exists('extend')) {
65
    /**
66
     * @param  string  $abstract
67
     * @param  Closure  $closure
68
     *
69
     * @return void
70
     */
71
    function extend(string $abstract, Closure $closure): void
72
    {
73 1
        app()->extend($abstract, $closure);
74
    }
75
}
76
77
if (! function_exists('instance')) {
78
    /**
79
     * @param  string  $abstract
80
     * @param  mixed  $instance
81
     *
82
     * @return void
83
     */
84
    function instance(string $abstract, mixed $instance): void
85
    {
86 1
        app()->instance($abstract, $instance);
87
    }
88
}
89