@@ -18,34 +18,34 @@ |
||
18 | 18 | */ |
19 | 19 | public static function get($key) |
20 | 20 | { |
21 | - if(file_exists(serviceJson())){ |
|
21 | + if (file_exists(serviceJson())) { |
|
22 | 22 | JsonHandler::$file = serviceJson(); |
23 | 23 | $serviceJson = JsonHandler::get(); |
24 | 24 | |
25 | - $dottedKey = explode('.',$key); |
|
25 | + $dottedKey = explode('.', $key); |
|
26 | 26 | |
27 | - if(count($dottedKey)==2){ |
|
27 | + if (count($dottedKey)==2) { |
|
28 | 28 | |
29 | - if(isset($serviceJson['container'][$dottedKey[0]][$dottedKey[1]])){ |
|
29 | + if (isset($serviceJson['container'][$dottedKey[0]][$dottedKey[1]])) { |
|
30 | 30 | $arrayData = $serviceJson['container'][$dottedKey[0]][$dottedKey[1]]; |
31 | 31 | |
32 | - if($serviceJson['container-format'][$dottedKey[0]][$dottedKey[1]]=='string'){ |
|
32 | + if ($serviceJson['container-format'][$dottedKey[0]][$dottedKey[1]]=='string') { |
|
33 | 33 | return $arrayData; |
34 | 34 | } |
35 | 35 | |
36 | - if($serviceJson['container-format'][$dottedKey[0]][$dottedKey[1]]=='closure'){ |
|
36 | + if ($serviceJson['container-format'][$dottedKey[0]][$dottedKey[1]]=='closure') { |
|
37 | 37 | return SuperClosure::get($arrayData); |
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
41 | - else{ |
|
41 | + else { |
|
42 | 42 | |
43 | - if(isset($serviceJson['container'][$key])){ |
|
44 | - if($serviceJson['container-format'][$key]=='string'){ |
|
43 | + if (isset($serviceJson['container'][$key])) { |
|
44 | + if ($serviceJson['container-format'][$key]=='string') { |
|
45 | 45 | return $serviceJson['container'][$key]; |
46 | 46 | } |
47 | 47 | |
48 | - if($serviceJson['container-format'][$key]=='closure'){ |
|
48 | + if ($serviceJson['container-format'][$key]=='closure') { |
|
49 | 49 | return SuperClosure::get($serviceJson['container'][$key]); |
50 | 50 | } |
51 | 51 | } |
@@ -37,8 +37,7 @@ |
||
37 | 37 | return SuperClosure::get($arrayData); |
38 | 38 | } |
39 | 39 | } |
40 | - } |
|
41 | - else{ |
|
40 | + } else{ |
|
42 | 41 | |
43 | 42 | if(isset($serviceJson['container'][$key])){ |
44 | 43 | if($serviceJson['container-format'][$key]=='string'){ |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @throws FileNotFoundException |
28 | 28 | */ |
29 | - private function applyProvider($key,$provider,$method='register') |
|
29 | + private function applyProvider($key, $provider, $method = 'register') |
|
30 | 30 | { |
31 | 31 | // If the provider classes are a real object |
32 | 32 | // we will run them. |
33 | - if(Utils::isNamespaceExists($provider)){ |
|
33 | + if (Utils::isNamespaceExists($provider)) { |
|
34 | 34 | |
35 | 35 | // after determining whether the register or boot methods |
36 | 36 | // we are running the provider. |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | $providerInstance = $this->app->resolve($provider); |
39 | 39 | |
40 | 40 | //we need to do method check for provider. |
41 | - if(method_exists($providerInstance,$method)){ |
|
41 | + if (method_exists($providerInstance, $method)) { |
|
42 | 42 | $providerInstance->{$method}(); |
43 | 43 | |
44 | - if($method=="register"){ |
|
44 | + if ($method=="register") { |
|
45 | 45 | /** @scrutinizer ignore-call */ |
46 | - $this->app->register('loadedProviders',$key,$provider); |
|
47 | - $this->deferrableProvider($providerInstance,$provider); |
|
46 | + $this->app->register('loadedProviders', $key, $provider); |
|
47 | + $this->deferrableProvider($providerInstance, $provider); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
@@ -58,56 +58,56 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @throws FileNotFoundException |
60 | 60 | */ |
61 | - private function deferrableProvider($providerInstance,$provider) |
|
61 | + private function deferrableProvider($providerInstance, $provider) |
|
62 | 62 | { |
63 | - if($providerInstance instanceof DeferrableProvider && file_exists(serviceJson())){ |
|
63 | + if ($providerInstance instanceof DeferrableProvider && file_exists(serviceJson())) { |
|
64 | 64 | $deferrableProvides = $providerInstance->provides(); |
65 | 65 | |
66 | 66 | foreach ($deferrableProvides as $deferrableProvide) { |
67 | - if($this->app->has($deferrableProvide)){ |
|
67 | + if ($this->app->has($deferrableProvide)) { |
|
68 | 68 | JsonHandler::$file = serviceJson(); |
69 | 69 | $serviceJson = JsonHandler::get(); |
70 | 70 | |
71 | - if(!isset($serviceJson['providers'][$provider])){ |
|
72 | - JsonHandler::set('providers-deferrable-classes',[ |
|
71 | + if (!isset($serviceJson['providers'][$provider])) { |
|
72 | + JsonHandler::set('providers-deferrable-classes', [ |
|
73 | 73 | $provider => true |
74 | 74 | ]); |
75 | 75 | |
76 | 76 | $container = $this->app->get($deferrableProvide); |
77 | 77 | |
78 | - if(!is_array($container)){ |
|
78 | + if (!is_array($container)) { |
|
79 | 79 | |
80 | - if($container instanceof \Closure){ |
|
81 | - JsonHandler::set('container',[ |
|
80 | + if ($container instanceof \Closure) { |
|
81 | + JsonHandler::set('container', [ |
|
82 | 82 | $deferrableProvide => SuperClosure::set($container) |
83 | 83 | ]); |
84 | 84 | |
85 | - JsonHandler::set('container-format',[ |
|
85 | + JsonHandler::set('container-format', [ |
|
86 | 86 | $deferrableProvide => 'closure' |
87 | 87 | ]); |
88 | 88 | } |
89 | - else{ |
|
90 | - JsonHandler::set('container',[ |
|
89 | + else { |
|
90 | + JsonHandler::set('container', [ |
|
91 | 91 | $deferrableProvide => $container |
92 | 92 | ]); |
93 | 93 | |
94 | - JsonHandler::set('container-format',[ |
|
94 | + JsonHandler::set('container-format', [ |
|
95 | 95 | $deferrableProvide => 'string' |
96 | 96 | ]); |
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
100 | - else{ |
|
100 | + else { |
|
101 | 101 | foreach ($container as $containerKey=>$containerItem) { |
102 | - if($containerItem instanceof \Closure){ |
|
103 | - JsonHandler::set('container.'.$deferrableProvide.'.'.$containerKey.'',SuperClosure::set($containerItem)); |
|
102 | + if ($containerItem instanceof \Closure) { |
|
103 | + JsonHandler::set('container.'.$deferrableProvide.'.'.$containerKey.'', SuperClosure::set($containerItem)); |
|
104 | 104 | |
105 | - JsonHandler::set('container-format.'.$deferrableProvide.'.'.$containerKey,'closure'); |
|
105 | + JsonHandler::set('container-format.'.$deferrableProvide.'.'.$containerKey, 'closure'); |
|
106 | 106 | } |
107 | - else{ |
|
108 | - JsonHandler::set('container.'.$deferrableProvide.'.'.$containerKey.'',$containerItem); |
|
107 | + else { |
|
108 | + JsonHandler::set('container.'.$deferrableProvide.'.'.$containerKey.'', $containerItem); |
|
109 | 109 | |
110 | - JsonHandler::set('container-format.'.$deferrableProvide.'.'.$containerKey,'string'); |
|
110 | + JsonHandler::set('container-format.'.$deferrableProvide.'.'.$containerKey, 'string'); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | */ |
127 | 127 | private function assignerLoadedProvidersInitialCoreValue() |
128 | 128 | { |
129 | - if(!isset($this->app['loadedProviders'])){ |
|
129 | + if (!isset($this->app['loadedProviders'])) { |
|
130 | 130 | |
131 | 131 | // for loaded providers, |
132 | 132 | // we register an empty array for the container object. |
133 | 133 | /** @scrutinizer ignore-call */ |
134 | - $this->app->register('loadedProviders',[]); |
|
134 | + $this->app->register('loadedProviders', []); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | /** @scrutinizer ignore-call */ |
147 | 147 | $providers = $this->app->serviceProviders(); |
148 | 148 | |
149 | - if(count($providers)){ |
|
149 | + if (count($providers)) { |
|
150 | 150 | $this->providers = $providers; |
151 | 151 | } |
152 | 152 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function handle() |
162 | 162 | { |
163 | - define ('serviceprovider',true); |
|
163 | + define('serviceprovider', true); |
|
164 | 164 | |
165 | 165 | //check providers and resolve |
166 | 166 | $this->resolveProviders($this->getServiceProviders()); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @throws FileNotFoundException |
175 | 175 | */ |
176 | - public function resolveProviders($providers=array()) |
|
176 | + public function resolveProviders($providers = array()) |
|
177 | 177 | { |
178 | 178 | // for loaded providers, |
179 | 179 | // we register an empty array for the container object. |
@@ -182,36 +182,36 @@ discard block |
||
182 | 182 | $serviceJson = []; |
183 | 183 | |
184 | 184 | //first we are running register methods of provider classes. |
185 | - foreach($providers as $key=>$provider){ |
|
185 | + foreach ($providers as $key=>$provider) { |
|
186 | 186 | |
187 | - if(file_exists(serviceJson())){ |
|
187 | + if (file_exists(serviceJson())) { |
|
188 | 188 | JsonHandler::$file = serviceJson(); |
189 | 189 | $serviceJson = JsonHandler::get(); |
190 | 190 | } |
191 | 191 | |
192 | 192 | // providers can only be installed once. |
193 | 193 | // apply providers and register for kernel |
194 | - if(!isset($this->app['loadedProviders'][$key])){ |
|
194 | + if (!isset($this->app['loadedProviders'][$key])) { |
|
195 | 195 | |
196 | - if(is_array($provider) && isset($provider['status']) && $provider['status']){ |
|
197 | - if(!isset($serviceJson['providers-deferrable-classes'][$provider['class']])){ |
|
198 | - $this->applyProvider($key,$provider['class']); |
|
196 | + if (is_array($provider) && isset($provider['status']) && $provider['status']) { |
|
197 | + if (!isset($serviceJson['providers-deferrable-classes'][$provider['class']])) { |
|
198 | + $this->applyProvider($key, $provider['class']); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | } |
202 | - else{ |
|
203 | - $this->applyProvider($key,$provider); |
|
202 | + else { |
|
203 | + $this->applyProvider($key, $provider); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | 209 | //then we are running boot methods of provider classes. |
210 | - foreach($providers as $key=>$provider){ |
|
210 | + foreach ($providers as $key=>$provider) { |
|
211 | 211 | |
212 | 212 | //if the providers register is already booted. |
213 | - if(isset($this->app['loadedProviders'][$key])){ |
|
214 | - $this->applyProvider($key,$provider,'boot'); |
|
213 | + if (isset($this->app['loadedProviders'][$key])) { |
|
214 | + $this->applyProvider($key, $provider, 'boot'); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | } |
@@ -85,8 +85,7 @@ discard block |
||
85 | 85 | JsonHandler::set('container-format',[ |
86 | 86 | $deferrableProvide => 'closure' |
87 | 87 | ]); |
88 | - } |
|
89 | - else{ |
|
88 | + } else{ |
|
90 | 89 | JsonHandler::set('container',[ |
91 | 90 | $deferrableProvide => $container |
92 | 91 | ]); |
@@ -96,15 +95,13 @@ discard block |
||
96 | 95 | ]); |
97 | 96 | } |
98 | 97 | |
99 | - } |
|
100 | - else{ |
|
98 | + } else{ |
|
101 | 99 | foreach ($container as $containerKey=>$containerItem) { |
102 | 100 | if($containerItem instanceof \Closure){ |
103 | 101 | JsonHandler::set('container.'.$deferrableProvide.'.'.$containerKey.'',SuperClosure::set($containerItem)); |
104 | 102 | |
105 | 103 | JsonHandler::set('container-format.'.$deferrableProvide.'.'.$containerKey,'closure'); |
106 | - } |
|
107 | - else{ |
|
104 | + } else{ |
|
108 | 105 | JsonHandler::set('container.'.$deferrableProvide.'.'.$containerKey.'',$containerItem); |
109 | 106 | |
110 | 107 | JsonHandler::set('container-format.'.$deferrableProvide.'.'.$containerKey,'string'); |
@@ -198,8 +195,7 @@ discard block |
||
198 | 195 | $this->applyProvider($key,$provider['class']); |
199 | 196 | } |
200 | 197 | |
201 | - } |
|
202 | - else{ |
|
198 | + } else{ |
|
203 | 199 | $this->applyProvider($key,$provider); |
204 | 200 | } |
205 | 201 |