Passed
Push — master ( 07890b...2a1b1e )
by Afshin
02:34
created
bootstrap/app.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@
 block discarded – undo
17 17
 }
18 18
 $i=0;
19 19
 foreach($filesInConfig as $config_file){
20
-	if($config_file === 'phpmig.php'){continue;}
21
-	$file[$i] = include_once  __APP_ROOT__.'config/'.$config_file;
22
-	if(is_array($file[$i])){
23
-		$configs = array_merge($configs, $file[$i]);
24
-		$i++;
25
-	}
20
+    if($config_file === 'phpmig.php'){continue;}
21
+    $file[$i] = include_once  __APP_ROOT__.'config/'.$config_file;
22
+    if(is_array($file[$i])){
23
+        $configs = array_merge($configs, $file[$i]);
24
+        $i++;
25
+    }
26 26
 
27 27
 }
28 28
 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,24 +1,24 @@  discard block
 block discarded – undo
1 1
 <?php
2
-define('__APP_ROOT__',__DIR__ . '/../') ;
2
+define('__APP_ROOT__', __DIR__ . '/../');
3 3
 $APPROOT = __APP_ROOT__;
4
-require  __APP_ROOT__.'bootstrap/bootstrap.php';
5
-require __APP_ROOT__.'vendor/autoload.php';
4
+require  __APP_ROOT__ . 'bootstrap/bootstrap.php';
5
+require __APP_ROOT__ . 'vendor/autoload.php';
6 6
 
7 7
 $env = new \Core\Helpers\Env();
8 8
 defined('DS') || define('DS', DIRECTORY_SEPARATOR);
9 9
 
10 10
 /*Dynamic containers in services*/
11
-$config_dir = scandir(__APP_ROOT__.'/config/');
11
+$config_dir = scandir(__APP_ROOT__ . '/config/');
12 12
 $ex_config_folders = array('..', '.');
13
-$filesInConfig =  array_diff($config_dir,$ex_config_folders);
13
+$filesInConfig = array_diff($config_dir, $ex_config_folders);
14 14
 if (!isset($configs)) {
15 15
     $configs = array();
16 16
 }
17
-$i=0;
18
-foreach($filesInConfig as $config_file){
19
-	if($config_file === 'phpmig.php'){continue;}
20
-	$file[$i] = include_once  __APP_ROOT__.'config/'.$config_file;
21
-	if(is_array($file[$i])){
17
+$i = 0;
18
+foreach ($filesInConfig as $config_file) {
19
+	if ($config_file === 'phpmig.php') {continue; }
20
+	$file[$i] = include_once  __APP_ROOT__ . 'config/' . $config_file;
21
+	if (is_array($file[$i])) {
22 22
 		$configs = array_merge($configs, $file[$i]);
23 23
 		$i++;
24 24
 	}
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 }
27 27
 
28 28
 $config['settings'] = $configs;
29
-require  __APP_ROOT__.'core/Functions/general_helpers.php';
29
+require  __APP_ROOT__ . 'core/Functions/general_helpers.php';
30 30
 
31 31
 $app = new \Core\App($config);
32
-if($config['settings']['app']['debug'] && !$config['settings']['tracy']['active']){
32
+if ($config['settings']['app']['debug'] && !$config['settings']['tracy']['active']) {
33 33
     error_reporting(-1);
34 34
     ini_set('display_errors', 1);
35 35
     ini_set('display_startup_errors', 1);
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 
39 39
 use SlimFacades\Facade;
40 40
 // get container app
41
-require __APP_ROOT__.'bootstrap/dependencies.php';
42
-require  __APP_ROOT__.'bootstrap/routes.php';
43
-require  __APP_ROOT__.'core/Functions/helpers.php';
44
-if(php_sapi_name() != 'cli') {
45
-    if($config['settings']['app']['debug'] && (int)$config['settings']['tracy']['active']){
41
+require __APP_ROOT__ . 'bootstrap/dependencies.php';
42
+require  __APP_ROOT__ . 'bootstrap/routes.php';
43
+require  __APP_ROOT__ . 'core/Functions/helpers.php';
44
+if (php_sapi_name() != 'cli') {
45
+    if ($config['settings']['app']['debug'] && (int) $config['settings']['tracy']['active']) {
46 46
         Tracy\Debugger::enable(Tracy\Debugger::DEVELOPMENT, $config['settings']['tracy']['path']);
47 47
     }
48 48
     Facade::setFacadeApplication($app);
49 49
 
50
-    require  __APP_ROOT__.'bootstrap/middlewares.php';
50
+    require  __APP_ROOT__ . 'bootstrap/middlewares.php';
51 51
 
52 52
     $app->run();
53 53
 
Please login to merge, or discard this patch.
core/Helpers/Env.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@
 block discarded – undo
11 11
 
12 12
 class Env
13 13
 {
14
-    public function __invoke($filePath ,$key, $default = null)
14
+    public function __invoke($filePath, $key, $default = null)
15 15
     {
16 16
         if (file_exists($filePath . '.env')) {
17
-            $_dotenv = new Dotenv($filePath );
17
+            $_dotenv = new Dotenv($filePath);
18 18
             $_dotenv->load();
19 19
             unset($_dotenv);
20 20
         }else {
Please login to merge, or discard this patch.
core/Services/AuthService.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,10 +63,10 @@
 block discarded – undo
63 63
                 $_SESSION['user']['mobile'] = $user->mobile;
64 64
 
65 65
 
66
-               setcookie('user', [
67
-                  'user_id'=>$user->id,
68
-                  'mobile'=>$user->mobile,
69
-               ], time() + (86400 * 30), "/"); // 86400 = 1 day *30 => 30 day
66
+                setcookie('user', [
67
+                    'user_id'=>$user->id,
68
+                    'mobile'=>$user->mobile,
69
+                ], time() + (86400 * 30), "/"); // 86400 = 1 day *30 => 30 day
70 70
 
71 71
 
72 72
                 return [
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 {
18 18
     public function user()
19 19
     {
20
-        if(isset($_Cookie['user'])){
20
+        if (isset($_Cookie['user'])) {
21 21
             $_SESSION['user'] = $_Cookie['user'];
22 22
         }
23 23
         return UserDataAccess::getUserById(isset($_SESSION['user']['user_id']) ? $_SESSION['user']['user_id'] : 0);
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function hasRole($roleName)
27 27
     {
28
-        if(!self::check()){
28
+        if (!self::check()) {
29 29
             return false;
30 30
         }
31
-        $userRoles =  UserDataAccess::getUserRoles(isset($_SESSION['user']['user_id']) ? $_SESSION['user']['user_id'] : 0);
31
+        $userRoles = UserDataAccess::getUserRoles(isset($_SESSION['user']['user_id']) ? $_SESSION['user']['user_id'] : 0);
32 32
         $hasAccess = false;
33
-        foreach ($userRoles as $role){
34
-            if($role->name == $roleName){
33
+        foreach ($userRoles as $role) {
34
+            if ($role->name == $roleName) {
35 35
                 $hasAccess = true;
36 36
                 break;
37 37
             }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         return isset($_SESSION['user']['user_id']);
46 46
     }
47 47
 
48
-    public function attempt(string $loginField,string $password)
48
+    public function attempt(string $loginField, string $password)
49 49
     {
50 50
         $user = UserDataAccess::getUserLoginField($loginField);
51 51
         if (!$user) {
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
             ];
56 56
         }
57 57
         $setting = Config::get('settings.auth');
58
-        if(1 || $setting['2step']){
59
-            return $this->twoStepAuth($loginField,$password);
60
-        }else{
61
-            if ($this->checkPass($password,$user->password)) {
58
+        if (1 || $setting['2step']) {
59
+            return $this->twoStepAuth($loginField, $password);
60
+        }else {
61
+            if ($this->checkPass($password, $user->password)) {
62 62
                 $_SESSION['user']['user_id'] = $user->id;
63 63
                 $_SESSION['user']['mobile'] = $user->mobile;
64 64
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
                     'type'=>'success',
74 74
                     'message'=> 'Logined',
75 75
                 ];
76
-            }else{
76
+            }else {
77 77
                 return [
78 78
                     'type'=>'error',
79 79
                     'message'=> 'password mismatch',
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
 
89 89
 
90 90
 
91
-    public function checkPass($password,$database_pass)
91
+    public function checkPass($password, $database_pass)
92 92
     {
93
-        if($database_pass == $password){
93
+        if ($database_pass == $password) {
94 94
             return true;
95 95
         }
96 96
         return false;
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
     }
99 99
 
100 100
 
101
-    public function twoStepAuth(string $loginField,string $password)
101
+    public function twoStepAuth(string $loginField, string $password)
102 102
     {
103 103
         $user = UserDataAccess::getUserLoginField($loginField);
104
-        if(UserDataAccess::checkToken($password,$loginField)){
104
+        if (UserDataAccess::checkToken($password, $loginField)) {
105 105
             $_SESSION['user']['user_id'] = $user->id;
106 106
             $_SESSION['user']['mobile'] = $user->mobile;
107 107
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                 'type'=>'success',
110 110
                 'message'=> 'Logined',
111 111
             ];
112
-        }else{
112
+        }else {
113 113
             return [
114 114
                 'type'=>'error',
115 115
                 'message'=> 'problem!',
Please login to merge, or discard this patch.
core/Functions/helpers.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function route(string $name ,array $params = [])
3
+function route(string $name, array $params = [])
4 4
 {
5 5
     $url = new \Core\Helpers\Url($GLOBALS['container']);
6
-    return $url->get($name , $params);
6
+    return $url->get($name, $params);
7 7
 }
8 8
 
9
-function url(string $name ,array $params = [])
9
+function url(string $name, array $params = [])
10 10
 {
11 11
     $url = new \Core\Helpers\Url($GLOBALS['container']);
12
-    return $url->get($name , $params);
12
+    return $url->get($name, $params);
13 13
 }
14 14
 
15 15
 // translate
16
-function trans($key , $replace = []){
16
+function trans($key, $replace = []) {
17 17
     $container = $GLOBALS['container'];
18
-    return $container->translator->trans($key,$replace);
18
+    return $container->translator->trans($key, $replace);
19 19
 }
20 20
 
21 21
 function public_path(string $uri = '') {
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     $url = new \Core\Helpers\Url($container);
27 27
 
28
-    $url_asset = $url->getBasePath($request) .'/'. $uri;
28
+    $url_asset = $url->getBasePath($request) . '/' . $uri;
29 29
     return $url_asset;
30 30
 }
31 31
 
@@ -78,17 +78,17 @@  discard block
 block discarded – undo
78 78
 
79 79
 function asset(string $uri = '') {
80 80
     $url = public_path();
81
-    $url_asset = $url.'assets/'.$uri;
81
+    $url_asset = $url . 'assets/' . $uri;
82 82
     return $url_asset;
83 83
 }
84 84
 
85
-function get_gravatar( $email, $s = 380, $d = 'mm', $r = 'g', $img = false, $atts = array() ) {
85
+function get_gravatar($email, $s = 380, $d = 'mm', $r = 'g', $img = false, $atts = array()) {
86 86
     $url = 'https://www.gravatar.com/avatar/';
87
-    $url .= md5( strtolower( trim( $email ) ) );
87
+    $url .= md5(strtolower(trim($email)));
88 88
     $url .= "?s=$s&d=$d&r=$r";
89
-    if ( $img ) {
89
+    if ($img) {
90 90
         $url = '<img src="' . $url . '"';
91
-        foreach ( $atts as $key => $val )
91
+        foreach ($atts as $key => $val)
92 92
             $url .= ' ' . $key . '="' . $val . '"';
93 93
         $url .= ' />';
94 94
     }
Please login to merge, or discard this patch.
bootstrap/dependencies.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 $container = $app->getContainer();
6 6
 
7 7
 /* database connection */
8
-$container['db'] = function ($container) {
8
+$container['db'] = function($container) {
9 9
     $db = $container['settings']['databases']['db'];
10 10
     $pdo = new PDO("mysql:host=" . $db['host'] . ";dbname=" . $db['database'],
11 11
         $db['username'], $db['password']);
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 //
54 54
 
55 55
 
56
-$container['generalErrorHandler'] = function ($container) {
56
+$container['generalErrorHandler'] = function($container) {
57 57
     return new \Core\Handlers\GeneralErrorHandler($container);
58 58
 };
59 59
 
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 // };
67 67
 
68 68
 // Service factory for the ORM
69
-$container['validator'] = function () {
69
+$container['validator'] = function() {
70 70
     return new App\Validation\Validator();
71 71
 };
72 72
 
73 73
 
74
-$container['eloquent'] = function ($container) {
74
+$container['eloquent'] = function($container) {
75 75
     $db = $container['settings']['databases']['db'];
76 76
 
77 77
     $capsule = new \Illuminate\Database\Capsule\Manager;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 $capsule->bootEloquent();
91 91
 
92 92
 // monolog
93
-$container['logger'] = function ($container) {
93
+$container['logger'] = function($container) {
94 94
     $settings = $container->get('settings')['app']['logger'];
95 95
     $logger = new Monolog\Logger($settings['name']);
96 96
     $logger->pushProcessor(new Monolog\Processor\UidProcessor());
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 };
100 100
 
101 101
 // not found handler
102
-$container['notFoundHandler'] = function ($container) {
103
-    return function (\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) {
102
+$container['notFoundHandler'] = function($container) {
103
+    return function(\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) {
104 104
         return $container['view']->render($response->withStatus(404), '404');
105 105
     };
106 106
 };
@@ -110,22 +110,22 @@  discard block
 block discarded – undo
110 110
 $translator = new \Core\Translator\Translator($container);
111 111
 $translator->init();
112 112
 
113
-$container['translator'] = function () use ($translator) {
113
+$container['translator'] = function() use ($translator) {
114 114
     return $translator;
115 115
 };
116 116
 
117 117
 
118 118
 // Register provider
119
-$container['flash'] = function () {
119
+$container['flash'] = function() {
120 120
     return new \Slim\Flash\Messages();
121 121
 };
122 122
 
123 123
 
124 124
 //
125
-$container['session'] = function ($container)  {
125
+$container['session'] = function($container) {
126 126
     $setting_session_driver = $container['settings']['session']['driver'] ?? 'session';
127 127
     $sessionOBJ = new \Core\Services\Session();
128
-    $session = $sessionOBJ->init($setting_session_driver) ;
128
+    $session = $sessionOBJ->init($setting_session_driver);
129 129
     return $session;
130 130
 };
131 131
 
@@ -136,17 +136,17 @@  discard block
 block discarded – undo
136 136
 
137 137
 
138 138
 // Register Blade View helper
139
-$container['view'] = function ($container) {
139
+$container['view'] = function($container) {
140 140
     $messages = $container->flash->getMessages();
141 141
 
142
-    if(!is_dir('../app/View/cache')){
142
+    if (!is_dir('../app/View/cache')) {
143 143
         @mkdir('../app/View/cache');
144 144
     }
145 145
 
146 146
 
147 147
     $viewSettings = $container['settings']['view'];
148 148
     return new \Slim\Views\Blade(
149
-        [$viewSettings['blade_template_path'].$viewSettings['template']],
149
+        [$viewSettings['blade_template_path'] . $viewSettings['template']],
150 150
         $viewSettings['blade_cache_path'],
151 151
         null,
152 152
         [
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 };
159 159
 
160 160
 // Register Blade View helper
161
-$container['json'] = function ($container) {
161
+$container['json'] = function($container) {
162 162
     return new \Core\Handlers\JsonHandler();
163 163
 };
164 164
 
165
-$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function(){
165
+$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function() {
166 166
 
167 167
     return "<?php echo 'Hello Directive'; ?>";
168 168
 });
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 
177 177
 
178 178
 /*Dynamic containers in services*/
179
-$dir = scandir(__APP_ROOT__.'/core/Services/');
179
+$dir = scandir(__APP_ROOT__ . '/core/Services/');
180 180
 $ex_folders = array('..', '.');
181
-$filesInServices =  array_diff($dir,$ex_folders);
181
+$filesInServices = array_diff($dir, $ex_folders);
182 182
 
183
-foreach($filesInServices as $service){
184
-    $content = preg_replace('/.php/','',$service);
185
-    $container[$content] = function () use ($content){
186
-        $class =  '\\Core\\Services\\'.$content ;
183
+foreach ($filesInServices as $service) {
184
+    $content = preg_replace('/.php/', '', $service);
185
+    $container[$content] = function() use ($content){
186
+        $class = '\\Core\\Services\\' . $content;
187 187
         return new $class();
188 188
     };
189 189
 }
Please login to merge, or discard this patch.
config/tracy.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@
 block discarded – undo
9 9
         'showSlimEnvironmentPanel' => 1,
10 10
         'showSlimRequestPanel' => 1,
11 11
         'showSlimResponsePanel' => 1,
12
-        'showSlimContainer' =>1 ,
12
+        'showSlimContainer' =>1,
13 13
         'showEloquentORMPanel' => 1,
14
-        'showIdiormPanel' => 1,// > 0 mean you enable logging
14
+        'showIdiormPanel' => 1, // > 0 mean you enable logging
15 15
         // but show or not panel you decide in browser in panel selector
16
-        'showDoctrinePanel' => 'em',// here also enable logging and you must enter your Doctrine container name
16
+        'showDoctrinePanel' => 'em', // here also enable logging and you must enter your Doctrine container name
17 17
         // and also as above show or not panel you decide in browser in panel selector
18 18
         'showProfilerPanel' => 1,
19 19
         'showVendorVersionsPanel' => 1,
Please login to merge, or discard this patch.
config/app.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
     'displayErrorDetails' => true,
6 6
     'app' => [
7 7
         'log_timer' => true,
8
-        'debug'=>true ,
8
+        'debug'=>true,
9 9
         'image' => [
10 10
             'dir' =>  $APPROOT . '/public/uploads'
11 11
         ],
Please login to merge, or discard this patch.
config/databases.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@
 block discarded – undo
2 2
 return [
3 3
     'databases'=>[
4 4
         'db' => [
5
-            'driver'    => $env($APPROOT,'DB_DRIVER', 'mysql'),
6
-            'host'      => $env($APPROOT,'DB_HOST', 'localhost'),
7
-            'database'  => $env($APPROOT,'DB_NAME', 'cafesaba'),
8
-            'username'  => $env($APPROOT,'DB_USERNAME', 'root'),
9
-            'password'  => $env($APPROOT,'DB_PASS', ''),
10
-            'charset'   => $env($APPROOT,'DB_CHARSET', 'utf8'),
11
-            'collation' => $env($APPROOT,'DB_COLLATION', 'utf8_unicode_ci'),
12
-            'prefix'    => $env($APPROOT,'DB_PREFIX', ''),
13
-            'port'      => $env($APPROOT,'DB_PORT', 3306),
5
+            'driver'    => $env($APPROOT, 'DB_DRIVER', 'mysql'),
6
+            'host'      => $env($APPROOT, 'DB_HOST', 'localhost'),
7
+            'database'  => $env($APPROOT, 'DB_NAME', 'cafesaba'),
8
+            'username'  => $env($APPROOT, 'DB_USERNAME', 'root'),
9
+            'password'  => $env($APPROOT, 'DB_PASS', ''),
10
+            'charset'   => $env($APPROOT, 'DB_CHARSET', 'utf8'),
11
+            'collation' => $env($APPROOT, 'DB_COLLATION', 'utf8_unicode_ci'),
12
+            'prefix'    => $env($APPROOT, 'DB_PREFIX', ''),
13
+            'port'      => $env($APPROOT, 'DB_PORT', 3306),
14 14
         ],
15 15
     ]
16 16
 ];
17 17
\ No newline at end of file
Please login to merge, or discard this patch.