@@ -30,31 +30,31 @@ discard block |
||
30 | 30 | * @param bool $reports |
31 | 31 | * @return mixed|string |
32 | 32 | */ |
33 | - public static function annotationsLoaders($service,$arg,$reports=false) |
|
33 | + public static function annotationsLoaders($service, $arg, $reports = false) |
|
34 | 34 | { |
35 | 35 | static::$reports = $reports; |
36 | 36 | |
37 | 37 | //factory runner |
38 | - if($service=="factory"){ |
|
38 | + if ($service=="factory") { |
|
39 | 39 | return self::factory(); |
40 | 40 | } |
41 | 41 | //if $name starts with $needles for repository |
42 | - if(Str::endsWith($service,'Repository')){ |
|
42 | + if (Str::endsWith($service, 'Repository')) { |
|
43 | 43 | return self::repository($service); |
44 | 44 | } |
45 | 45 | |
46 | 46 | //if $name starts with $needles for source |
47 | - if(Str::endsWith($service,'Source')){ |
|
48 | - return self::source($service,$arg); |
|
47 | + if (Str::endsWith($service, 'Source')) { |
|
48 | + return self::source($service, $arg); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | //if $name starts with $needles for model |
52 | - if(Str::endsWith($service,'Builder')){ |
|
52 | + if (Str::endsWith($service, 'Builder')) { |
|
53 | 53 | return self::Builder(ucfirst($service)); |
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | - if(method_exists(new self,$service)){ |
|
57 | + if (method_exists(new self, $service)) { |
|
58 | 58 | return self::$service($arg); |
59 | 59 | } |
60 | 60 | |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | */ |
107 | 107 | private static function builder($service) |
108 | 108 | { |
109 | - if(static::$reports){ |
|
110 | - self::writeTrace(debug_backtrace(),'builders',$service); |
|
109 | + if (static::$reports) { |
|
110 | + self::writeTrace(debug_backtrace(), 'builders', $service); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | //we are making a namespace assignment for the builder. |
114 | - $builder=app()->namespace()->builder().'\BuilderMap'; |
|
114 | + $builder = app()->namespace()->builder().'\BuilderMap'; |
|
115 | 115 | |
116 | 116 | //we are getting builder instance. |
117 | 117 | return app()->resolve($builder); |
@@ -139,16 +139,16 @@ discard block |
||
139 | 139 | * @param array $bind |
140 | 140 | * @return mixed |
141 | 141 | */ |
142 | - public function container($instance,$class,$bind=array()) |
|
142 | + public function container($instance, $class, $bind = array()) |
|
143 | 143 | { |
144 | - if(!property_exists($instance->container(),$class)){ |
|
144 | + if (!property_exists($instance->container(), $class)) { |
|
145 | 145 | throw new \InvalidArgumentException('container object false for ('.$class.') object'); |
146 | 146 | } |
147 | 147 | |
148 | - $container=$instance->container()->{$class}; |
|
148 | + $container = $instance->container()->{$class}; |
|
149 | 149 | |
150 | - if(!is_array($instance->container()->{$class}) AND Utils::isNamespaceExists($container)){ |
|
151 | - return $instance->resolve($container,$bind); |
|
150 | + if (!is_array($instance->container()->{$class}) AND Utils::isNamespaceExists($container)) { |
|
151 | + return $instance->resolve($container, $bind); |
|
152 | 152 | } |
153 | 153 | return $instance->container()->{$class}; |
154 | 154 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function createAppInstance($object) |
160 | 160 | { |
161 | - if(!defined('appInstance')){ |
|
162 | - define('appInstance',(base64_encode(serialize($object)))); |
|
161 | + if (!defined('appInstance')) { |
|
162 | + define('appInstance', (base64_encode(serialize($object)))); |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | * @param array $arg |
168 | 168 | * @return mixed |
169 | 169 | */ |
170 | - private static function date($arg=array()) |
|
170 | + private static function date($arg = array()) |
|
171 | 171 | { |
172 | - $locale = (count($arg)=="0") ? config('app.locale','en') : current($arg); |
|
172 | + $locale = (count($arg)=="0") ? config('app.locale', 'en') : current($arg); |
|
173 | 173 | |
174 | 174 | return app()->resolve(Date::class)->setLocale($locale); |
175 | 175 | } |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | { |
190 | 190 | //we save an instance for the entire application |
191 | 191 | //and add it to the helper file to be accessed from anywhere in the application. |
192 | - if(!isset(self::$instance['appInstance'])){ |
|
193 | - self::$instance['appInstance']=unserialize(base64_decode(appInstance)); |
|
192 | + if (!isset(self::$instance['appInstance'])) { |
|
193 | + self::$instance['appInstance'] = unserialize(base64_decode(appInstance)); |
|
194 | 194 | return self::$instance['appInstance']; |
195 | 195 | } |
196 | 196 | return self::$instance['appInstance']; |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | */ |
218 | 218 | private static function queue() |
219 | 219 | { |
220 | - if(!isset(self::$instance['queue'])){ |
|
220 | + if (!isset(self::$instance['queue'])) { |
|
221 | 221 | |
222 | - self::$instance['queue']=(new Queue()); |
|
222 | + self::$instance['queue'] = (new Queue()); |
|
223 | 223 | return self::$instance['queue']; |
224 | 224 | |
225 | 225 | } |
@@ -231,22 +231,22 @@ discard block |
||
231 | 231 | * @param bool $namespace |
232 | 232 | * @return string |
233 | 233 | */ |
234 | - public static function repository($service,$namespace=false) |
|
234 | + public static function repository($service, $namespace = false) |
|
235 | 235 | { |
236 | - if(static::$reports){ |
|
237 | - self::writeTrace(debug_backtrace(),'repositories',$service); |
|
236 | + if (static::$reports) { |
|
237 | + self::writeTrace(debug_backtrace(), 'repositories', $service); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | //I can get the repository name from the magic method as a salt repository, |
241 | 241 | //after which we will edit it as an adapter namespace. |
242 | - $repositoryName=ucfirst(preg_replace('@Repository@is','',$service)); |
|
242 | + $repositoryName = ucfirst(preg_replace('@Repository@is', '', $service)); |
|
243 | 243 | |
244 | 244 | //If we then configure the name of the simple repository to be an adapter |
245 | 245 | //then we will give the user an example of the adapter class in each repository call. |
246 | 246 | $repositoryAdapterName = $repositoryName.'Adapter'; |
247 | 247 | $repositoryNamespace = app()->namespace()->repository().'\\'.$repositoryName.'\\'.$repositoryAdapterName; |
248 | 248 | |
249 | - if($namespace) return $repositoryNamespace; |
|
249 | + if ($namespace) return $repositoryNamespace; |
|
250 | 250 | |
251 | 251 | //and eventually we conclude the adapter class of the repository package as an instance. |
252 | 252 | return app()->resolve($repositoryNamespace)->adapter(); |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | /** |
256 | 256 | * @param $trace |
257 | 257 | */ |
258 | - private static function writeTrace($trace,$type,$service) |
|
258 | + private static function writeTrace($trace, $type, $service) |
|
259 | 259 | { |
260 | - if(self::app()->isLocale()){ |
|
260 | + if (self::app()->isLocale()) { |
|
261 | 261 | $trace = $trace[2]; |
262 | 262 | |
263 | 263 | $time = time(); |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | |
269 | 269 | $filenamespace = Utils::getNamespace($trace['file']); |
270 | 270 | |
271 | - if(!in_array($filenamespace,!is_array($getJsonFile) ? [] : $getJsonFile)){ |
|
272 | - JsonHandler::set('annotation.'.$type.'.'.$service.'.file.'.$time,$filenamespace); |
|
273 | - JsonHandler::set('annotation.'.$type.'.'.$service.'.line.'.$time,$trace['line']); |
|
271 | + if (!in_array($filenamespace, !is_array($getJsonFile) ? [] : $getJsonFile)) { |
|
272 | + JsonHandler::set('annotation.'.$type.'.'.$service.'.file.'.$time, $filenamespace); |
|
273 | + JsonHandler::set('annotation.'.$type.'.'.$service.'.line.'.$time, $trace['line']); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | } |
@@ -280,17 +280,17 @@ discard block |
||
280 | 280 | * @param $arg |
281 | 281 | * @return mixed |
282 | 282 | */ |
283 | - private static function source($service,$arg) |
|
283 | + private static function source($service, $arg) |
|
284 | 284 | { |
285 | 285 | //get Source path |
286 | - $service=ucfirst($service); |
|
287 | - $getCalledClass=str_replace('\\'.class_basename($arg[0]),'',get_class($arg[0])); |
|
288 | - $getCalledClass=class_basename($getCalledClass); |
|
286 | + $service = ucfirst($service); |
|
287 | + $getCalledClass = str_replace('\\'.class_basename($arg[0]), '', get_class($arg[0])); |
|
288 | + $getCalledClass = class_basename($getCalledClass); |
|
289 | 289 | |
290 | - $service=str_replace($getCalledClass,'',$service); |
|
290 | + $service = str_replace($getCalledClass, '', $service); |
|
291 | 291 | |
292 | 292 | //run service for endpoint |
293 | - $serviceSource=StaticPathModel::appSourceEndpoint().'\\'.$getCalledClass.'\\'.$service.'\Main'; |
|
293 | + $serviceSource = StaticPathModel::appSourceEndpoint().'\\'.$getCalledClass.'\\'.$service.'\Main'; |
|
294 | 294 | return app()->resolve($serviceSource); |
295 | 295 | } |
296 | 296 | |
@@ -299,9 +299,9 @@ discard block |
||
299 | 299 | */ |
300 | 300 | public static function redis() |
301 | 301 | { |
302 | - if(!isset(self::$instance['redis'])){ |
|
302 | + if (!isset(self::$instance['redis'])) { |
|
303 | 303 | |
304 | - self::$instance['redis']=(new Redis())->client(); |
|
304 | + self::$instance['redis'] = (new Redis())->client(); |
|
305 | 305 | return self::$instance['redis']; |
306 | 306 | |
307 | 307 | } |
@@ -312,13 +312,13 @@ discard block |
||
312 | 312 | * @param null $param |
313 | 313 | * @return array|null|string |
314 | 314 | */ |
315 | - public function route($param=null) |
|
315 | + public function route($param = null) |
|
316 | 316 | { |
317 | - $kernel=self::getAppInstance()->kernel; |
|
317 | + $kernel = self::getAppInstance()->kernel; |
|
318 | 318 | |
319 | - $saltRouteParameters=$kernel->routeParameters; |
|
319 | + $saltRouteParameters = $kernel->routeParameters; |
|
320 | 320 | |
321 | - if($param===null){ |
|
321 | + if ($param===null) { |
|
322 | 322 | return $saltRouteParameters; |
323 | 323 | } |
324 | 324 | |
@@ -334,25 +334,25 @@ discard block |
||
334 | 334 | * @param array $select |
335 | 335 | * @return mixed|string |
336 | 336 | */ |
337 | - public function translator($data,$select=array()) |
|
337 | + public function translator($data, $select = array()) |
|
338 | 338 | { |
339 | 339 | $languageDir = path()->appLanguage(); |
340 | 340 | |
341 | - $lang=(new Lingua($languageDir)); |
|
341 | + $lang = (new Lingua($languageDir)); |
|
342 | 342 | |
343 | - if(self::app()->has('locale')){ |
|
343 | + if (self::app()->has('locale')) { |
|
344 | 344 | $defaultLocale = self::app()->get('locale'); |
345 | 345 | } |
346 | - else{ |
|
346 | + else { |
|
347 | 347 | $defaultLocale = config('app.locale'); |
348 | 348 | } |
349 | 349 | |
350 | - if(!file_exists($languageDir.''.DIRECTORY_SEPARATOR.''.$defaultLocale)){ |
|
350 | + if (!file_exists($languageDir.''.DIRECTORY_SEPARATOR.''.$defaultLocale)) { |
|
351 | 351 | $defaultLocale = config('app.fallback_locale'); |
352 | 352 | } |
353 | 353 | |
354 | - if(count($select)){ |
|
355 | - return $lang->include(['default'])->locale($defaultLocale)->get($data,$select); |
|
354 | + if (count($select)) { |
|
355 | + return $lang->include(['default'])->locale($defaultLocale)->get($data, $select); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | return $lang->include(['default'])->locale($defaultLocale)->get($data); |