1 | <?php |
||
36 | class Service |
||
37 | { |
||
38 | /** |
||
39 | * @var ContainerInterface |
||
40 | * @staticvar |
||
41 | */ |
||
42 | protected static $container; |
||
43 | |||
44 | /** |
||
45 | * Finalized constructor to prevent instantiation. |
||
46 | * |
||
47 | * @access private |
||
48 | * @final |
||
49 | */ |
||
50 | final private function __construct() |
||
53 | |||
54 | /** |
||
55 | * Locate a service from the container |
||
56 | * |
||
57 | * @param string $id service id |
||
58 | * @return object |
||
59 | * @throws NotFoundException if container not set or object not found |
||
60 | * @throws RuntimeException if object instantiation error |
||
61 | */ |
||
62 | public static function get(string $id): object |
||
69 | |||
70 | /** |
||
71 | * Set the container |
||
72 | * |
||
73 | * @param ContainerInterface $container |
||
74 | * @return void |
||
75 | * @throws RuntimeException if container set already |
||
76 | */ |
||
77 | public static function setContainer(ContainerInterface $container = null): void |
||
87 | } |
||
88 |