Passed
Push — master ( 72408a...f36148 )
by Jesse
03:47
created

Container::get()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 9
rs 9.6666
c 2
b 0
f 0
cc 3
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Stratadox\Di;
4
5
use Closure;
6
use Psr\Container\ContainerInterface as PsrContainerInterface;
7
use Psr\Container\NotFoundExceptionInterface as NotFound;
8
9
interface Container extends PsrContainerInterface
10
{
11
    /**
12
     * Register a service to the container.
13
     *
14
     * @param string $service   The name of the service to register
15
     * @param Closure $factory  The function that produces the service
16
     * @param bool $cache       Whether or nor to cache the service
17
     *
18
     * @return void
19
     */
20
    public function set(string $service, Closure $factory, bool $cache = true): void;
21
22
    /**
23
     * Retrieve a service from the container.
24
     *
25
     * @param string $service   The name of the service to retrieve
26
     *
27
     * @return mixed            The service object
28
     *
29
     * @throws InvalidServiceDefinition
30
     * @throws NotFound
31
     */
32
    public function get($service);
33
34
    /**
35
     * Check whether a service is registered.
36
     *
37
     * @param string $service   The name of the service to check for
38
     *
39
     * @return boolean          Whether or not the service exists
40
     */
41
    public function has($service): bool;
42
43
    /**
44
     * Remove a service from the container.
45
     *
46
     * @param string $service   The name of the service to remove
47
     *
48
     * @return void
49
     */
50
    public function forget(string $service): void;
51
}
52