Passed
Push — master ( 9e17a2...a07f95 )
by Php Easy Api
02:43
created
src/resta/Foundation/ApplicationBaseRegister.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
         // if the store directory is available,
30 30
         // then the application process continues.
31 31
         // if not available, only the core is executed.
32
-        if(file_exists(app()->path()->storeDir())){
33
-            $this->app->register('isAvailableStore',true);
32
+        if (file_exists(app()->path()->storeDir())) {
33
+            $this->app->register('isAvailableStore', true);
34 34
         }
35
-        else{
36
-            $this->app->register('isAvailableStore',false);
35
+        else {
36
+            $this->app->register('isAvailableStore', false);
37 37
         }
38 38
     }
39 39
 
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
     {
48 48
         //we can use this method to move an instance of the application class with the kernel object
49 49
         //and easily resolve an encrypted instance of all the kernel variables in our helper class.
50
-        ClassAliasGroup::setAlias(App::class,'application');
50
+        ClassAliasGroup::setAlias(App::class, 'application');
51 51
 
52 52
         //set base instances
53 53
         $this->setBaseInstances();
54 54
 
55 55
         //we define the general application instance object.
56
-        define('appInstance',(base64_encode(serialize($this->app))));
56
+        define('appInstance', (base64_encode(serialize($this->app))));
57 57
 
58 58
         //main loader for application
59 59
         $this->mainLoader();
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
         // this function can be used for defining your own way of handling errors during runtime,
69 69
         // for example in applications in which you need to do cleanup of data/files when a critical error happens,
70 70
         // or when you need to trigger an error under certain conditions (using trigger_error()).
71
-        if($this->app['isAvailableStore']){
72
-            $this->app->make('exception',function(){
71
+        if ($this->app['isAvailableStore']) {
72
+            $this->app->make('exception', function() {
73 73
                 return ErrorProvider::class;
74 74
             });
75 75
         }
@@ -84,30 +84,30 @@  discard block
 block discarded – undo
84 84
     {
85 85
         // for revision records,
86 86
         // the master key is assigned as revision.
87
-        $this->app->register('revision',[]);
87
+        $this->app->register('revision', []);
88 88
 
89 89
         //we're saving the directory where kernel files are running to the kernel object.
90
-        $this->app->register('corePath',str_replace('Foundation','',__DIR__.''));
90
+        $this->app->register('corePath', str_replace('Foundation', '', __DIR__.''));
91 91
 
92 92
         //For the application, we create the object that the register method,
93 93
         // which is the container center, is connected to by the kernel object register method.
94
-        $this->app->register('container',$this->app);
94
+        $this->app->register('container', $this->app);
95 95
 
96 96
         // We are saving the application class to
97 97
         // the container object for the appClass value.
98
-        $this->app->register('appClass',new App());
98
+        $this->app->register('appClass', new App());
99 99
 
100 100
         //set closure bind instance for application
101
-        $this->app->register('appClosureInstance',ClosureDispatcher::bind(app()));
101
+        $this->app->register('appClosureInstance', ClosureDispatcher::bind(app()));
102 102
 
103 103
         //set closure bind instance for bootLoader class
104
-        $this->app->register('closureBootLoader',ClosureDispatcher::bind($this->app['bootLoader']));
104
+        $this->app->register('closureBootLoader', ClosureDispatcher::bind($this->app['bootLoader']));
105 105
 
106 106
         //set register for macro
107
-        $this->app->register('macro',$this->app->resolve(Macro::class));
107
+        $this->app->register('macro', $this->app->resolve(Macro::class));
108 108
 
109 109
         //set register for macro
110
-        $this->app->register('pipeline',new Pipeline());
110
+        $this->app->register('pipeline', new Pipeline());
111 111
 
112 112
     }
113 113
 
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
         //register as instance application object
122 122
         // and container instance resolve
123 123
         //set core instance value
124
-        $this->app->instance('container',$this->app->singleton());
125
-        $this->app->instance('bootLoader',$this->app->resolve(BootLoader::class));
126
-        $this->app->instance('containerInstanceResolve',ContainerInstanceResolver::class);
127
-        $this->app->instance('reflection',ReflectionProcess::class);
124
+        $this->app->instance('container', $this->app->singleton());
125
+        $this->app->instance('bootLoader', $this->app->resolve(BootLoader::class));
126
+        $this->app->instance('containerInstanceResolve', ContainerInstanceResolver::class);
127
+        $this->app->instance('reflection', ReflectionProcess::class);
128 128
     }
129 129
 
130 130
     /**
@@ -133,19 +133,19 @@  discard block
 block discarded – undo
133 133
     private function setGlobalAccessor()
134 134
     {
135 135
         //get response success and status
136
-        $this->app->register('instanceController',null);
137
-        $this->app->register('responseSuccess',true);
138
-        $this->app->register('responseStatus',200);
139
-        $this->app->register('responseType','json');
136
+        $this->app->register('instanceController', null);
137
+        $this->app->register('responseSuccess', true);
138
+        $this->app->register('responseStatus', 200);
139
+        $this->app->register('responseType', 'json');
140 140
 
141 141
         //we first load the response class as a singleton object to allow you to send output anywhere
142
-        $this->app->register('out',$this->app->resolve(ResponseProvider::class));
142
+        $this->app->register('out', $this->app->resolve(ResponseProvider::class));
143 143
 
144 144
         $requestService = "Store\Services\RequestService";
145 145
 
146 146
         //The HttpFoundation component defines an object-oriented layer for the HTTP specification.
147 147
         //The HttpFoundation component replaces these default PHP global variables and functions by an object-oriented layer
148
-        if(Utils::isNamespaceExists($requestService)){
148
+        if (Utils::isNamespaceExists($requestService)) {
149 149
 
150 150
             Request::setFactory(function(array $query = array(),
151 151
                                          array $request = array(),
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 
168 168
 
169 169
         //After registering the symfony request method, we also save the get and post methods for user convenience.
170
-        $this->app->register('request',Request::createFromGlobals());
171
-        $this->app->register('get',core()->request->query->all());
172
-        $this->app->register('post',core()->request->request->all());
170
+        $this->app->register('request', Request::createFromGlobals());
171
+        $this->app->register('get', core()->request->query->all());
172
+        $this->app->register('post', core()->request->request->all());
173 173
 
174 174
         //We determine with the kernel object which HTTP method the requested from the client
175
-        $this->app->register('httpMethod',ucfirst(strtolower(core()->request->getRealMethod())));
175
+        $this->app->register('httpMethod', ucfirst(strtolower(core()->request->getRealMethod())));
176 176
 
177
-        define('httpMethod',strtoupper(core()->httpMethod));
177
+        define('httpMethod', strtoupper(core()->httpMethod));
178 178
 
179
-        $this->app->register('fileSystem',new FileProcess());
179
+        $this->app->register('fileSystem', new FileProcess());
180 180
     }
181 181
 
182 182
 }
183 183
\ No newline at end of file
Please login to merge, or discard this patch.
src/resta/Support/App.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -21,36 +21,36 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * @var array
23 23
      */
24
-    protected static $instance=[];
24
+    protected static $instance = [];
25 25
 
26 26
     /**
27 27
      * @param $service
28 28
      * @param $arg
29 29
      * @return mixed
30 30
      */
31
-    public static function annotationsLoaders($service,$arg)
31
+    public static function annotationsLoaders($service, $arg)
32 32
     {
33 33
         //factory runner
34
-        if($service=="factory"){
34
+        if ($service=="factory") {
35 35
             return self::factory();
36 36
         }
37 37
         //if $name starts with $needles for repository
38
-        if(Str::endsWith($service,'Repository')){
38
+        if (Str::endsWith($service, 'Repository')) {
39 39
             return self::repository($service);
40 40
         }
41 41
 
42 42
         //if $name starts with $needles for source
43
-        if(Str::endsWith($service,'Source')){
44
-            return self::source($service,$arg);
43
+        if (Str::endsWith($service, 'Source')) {
44
+            return self::source($service, $arg);
45 45
         }
46 46
 
47 47
         //if $name starts with $needles for model
48
-        if(Str::endsWith($service,'Builder')){
48
+        if (Str::endsWith($service, 'Builder')) {
49 49
             return self::Builder(ucfirst($service));
50 50
         }
51 51
 
52 52
 
53
-        if(method_exists(new self,$service)){
53
+        if (method_exists(new self, $service)) {
54 54
             return self::$service($arg);
55 55
         }
56 56
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     private static function builder($service)
80 80
     {
81 81
         //we are making a namespace assignment for the builder.
82
-        $builder=app()->namespace()->builder().'\\'.$service;
82
+        $builder = app()->namespace()->builder().'\\'.$service;
83 83
 
84 84
         //we are getting builder instance.
85 85
         return app()->resolve($builder);
@@ -107,16 +107,16 @@  discard block
 block discarded – undo
107 107
      * @param array $bind
108 108
      * @return mixed
109 109
      */
110
-    public function container($instance,$class,$bind=array())
110
+    public function container($instance, $class, $bind = array())
111 111
     {
112
-        if(!property_exists($instance->container(),$class)){
112
+        if (!property_exists($instance->container(), $class)) {
113 113
             throw new \InvalidArgumentException('container object false for ('.$class.') object');
114 114
         }
115 115
 
116
-        $container=$instance->container()->{$class};
116
+        $container = $instance->container()->{$class};
117 117
 
118
-        if(!is_array($instance->container()->{$class}) AND Utils::isNamespaceExists($container)){
119
-            return $instance->resolve($container,$bind);
118
+        if (!is_array($instance->container()->{$class}) AND Utils::isNamespaceExists($container)) {
119
+            return $instance->resolve($container, $bind);
120 120
         }
121 121
         return $instance->container()->{$class};
122 122
     }
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function createAppInstance($object)
128 128
     {
129
-        if(!defined('appInstance')){
130
-            define('appInstance',(base64_encode(serialize($object))));
129
+        if (!defined('appInstance')) {
130
+            define('appInstance', (base64_encode(serialize($object))));
131 131
         }
132 132
     }
133 133
 
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
      * @param array $arg
136 136
      * @return mixed
137 137
      */
138
-    private static function date($arg=array())
138
+    private static function date($arg = array())
139 139
     {
140
-        $locale = (count($arg)=="0") ? config('app.locale','en') : current($arg);
140
+        $locale = (count($arg)=="0") ? config('app.locale', 'en') : current($arg);
141 141
 
142 142
        return app()->resolve(Date::class)->setLocale($locale);
143 143
     }
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
     {
158 158
         //we save an instance for the entire application
159 159
         //and add it to the helper file to be accessed from anywhere in the application.
160
-        if(!isset(self::$instance['appInstance'])){
161
-            self::$instance['appInstance']=unserialize(base64_decode(appInstance));
160
+        if (!isset(self::$instance['appInstance'])) {
161
+            self::$instance['appInstance'] = unserialize(base64_decode(appInstance));
162 162
             return self::$instance['appInstance'];
163 163
         }
164 164
         return self::$instance['appInstance'];
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
      */
186 186
     private static function queue()
187 187
     {
188
-        if(!isset(self::$instance['queue'])){
188
+        if (!isset(self::$instance['queue'])) {
189 189
 
190
-            self::$instance['queue']=(new Queue());
190
+            self::$instance['queue'] = (new Queue());
191 191
             return self::$instance['queue'];
192 192
 
193 193
         }
@@ -199,18 +199,18 @@  discard block
 block discarded – undo
199 199
      * @param bool $namespace
200 200
      * @return string
201 201
      */
202
-    public static function repository($service,$namespace=false)
202
+    public static function repository($service, $namespace = false)
203 203
     {
204 204
         //I can get the repository name from the magic method as a salt repository,
205 205
         //after which we will edit it as an adapter namespace.
206
-        $repositoryName=ucfirst(preg_replace('@Repository@is','',$service));
206
+        $repositoryName = ucfirst(preg_replace('@Repository@is', '', $service));
207 207
 
208 208
         //If we then configure the name of the simple repository to be an adapter
209 209
         //then we will give the user an example of the adapter class in each repository call.
210 210
         $repositoryAdapterName  = $repositoryName.'Adapter';
211 211
         $repositoryNamespace    = app()->namespace()->repository().'\\'.$repositoryName.'\\'.$repositoryAdapterName;
212 212
 
213
-        if($namespace) return $repositoryNamespace;
213
+        if ($namespace) return $repositoryNamespace;
214 214
 
215 215
         //and eventually we conclude the adapter class of the repository package as an instance.
216 216
         return app()->resolve($repositoryNamespace)->adapter();
@@ -221,17 +221,17 @@  discard block
 block discarded – undo
221 221
      * @param $arg
222 222
      * @return mixed
223 223
      */
224
-    private static function source($service,$arg)
224
+    private static function source($service, $arg)
225 225
     {
226 226
         //get Source path
227
-        $service=ucfirst($service);
228
-        $getCalledClass=str_replace('\\'.class_basename($arg[0]),'',get_class($arg[0]));
229
-        $getCalledClass=class_basename($getCalledClass);
227
+        $service = ucfirst($service);
228
+        $getCalledClass = str_replace('\\'.class_basename($arg[0]), '', get_class($arg[0]));
229
+        $getCalledClass = class_basename($getCalledClass);
230 230
 
231
-        $service=str_replace($getCalledClass,'',$service);
231
+        $service = str_replace($getCalledClass, '', $service);
232 232
 
233 233
         //run service for endpoint
234
-        $serviceSource=StaticPathModel::appSourceEndpoint().'\\'.$getCalledClass.'\\'.$service.'\Main';
234
+        $serviceSource = StaticPathModel::appSourceEndpoint().'\\'.$getCalledClass.'\\'.$service.'\Main';
235 235
         return app()->resolve($serviceSource);
236 236
     }
237 237
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
      */
241 241
     public static function redis()
242 242
     {
243
-        if(!isset(self::$instance['redis'])){
243
+        if (!isset(self::$instance['redis'])) {
244 244
 
245
-            self::$instance['redis']=(new Redis())->client();
245
+            self::$instance['redis'] = (new Redis())->client();
246 246
             return self::$instance['redis'];
247 247
 
248 248
         }
@@ -253,30 +253,30 @@  discard block
 block discarded – undo
253 253
      * @param null $param
254 254
      * @return array|null|string
255 255
      */
256
-    public function route($param=null)
256
+    public function route($param = null)
257 257
     {
258
-        $kernel=self::getAppInstance()->kernel;
258
+        $kernel = self::getAppInstance()->kernel;
259 259
 
260
-        $saltRouteParameters=$kernel->routeParameters;
261
-        $urlMethod=strtolower($kernel->urlComponent['method']);
260
+        $saltRouteParameters = $kernel->routeParameters;
261
+        $urlMethod = strtolower($kernel->urlComponent['method']);
262 262
 
263
-        $serviceConfRouteParameters=[];
264
-        if(isset($kernel->serviceConf['routeParameters'][$urlMethod])){
265
-            $serviceConfRouteParameters=$kernel->serviceConf['routeParameters'][$urlMethod];
263
+        $serviceConfRouteParameters = [];
264
+        if (isset($kernel->serviceConf['routeParameters'][$urlMethod])) {
265
+            $serviceConfRouteParameters = $kernel->serviceConf['routeParameters'][$urlMethod];
266 266
         }
267 267
 
268
-        $list=[];
268
+        $list = [];
269 269
 
270
-        foreach ($saltRouteParameters as $key=>$value){
271
-            if(isset($serviceConfRouteParameters[$key])){
272
-                $list[$serviceConfRouteParameters[$key]]=$value;
270
+        foreach ($saltRouteParameters as $key=>$value) {
271
+            if (isset($serviceConfRouteParameters[$key])) {
272
+                $list[$serviceConfRouteParameters[$key]] = $value;
273 273
             }
274
-            else{
275
-                $list[$key]=$value;
274
+            else {
275
+                $list[$key] = $value;
276 276
             }
277 277
         }
278 278
 
279
-        if($param===null){
279
+        if ($param===null) {
280 280
             return $list;
281 281
         }
282 282
 
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
      * @param array $select
289 289
      * @return mixed|string
290 290
      */
291
-    public function translator($data,$select=array())
291
+    public function translator($data, $select = array())
292 292
     {
293
-        $lang=(new Lingua(path()->appLanguage()));
293
+        $lang = (new Lingua(path()->appLanguage()));
294 294
 
295
-        $defaultLocale=config('app.locale');
295
+        $defaultLocale = config('app.locale');
296 296
 
297
-        if(count($select)){
298
-            return $lang->include(['default'])->locale($defaultLocale)->get($data,$select);
297
+        if (count($select)) {
298
+            return $lang->include(['default'])->locale($defaultLocale)->get($data, $select);
299 299
         }
300 300
 
301 301
         return $lang->include(['default'])->locale($defaultLocale)->get($data);
Please login to merge, or discard this patch.