Passed
Push — main ( 915a08...2be97f )
by Sammy
01:45
created
Auth/Operator.class.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 
13 13
   use Permissionability;
14 14
 
15
-	public function __toString()
15
+  public function __toString()
16 16
   {
17 17
     return $this->get('username');
18 18
   }
19 19
 
20
-	public function is_active() : bool
20
+  public function is_active() : bool
21 21
   {
22 22
     return !empty($this->get('active'));
23 23
   }
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
   }
39 39
 
40 40
   public function password_change($string)
41
-	{
42
-		$this->password = password_hash($string, PASSWORD_DEFAULT);
43
-	}
41
+  {
42
+    $this->password = password_hash($string, PASSWORD_DEFAULT);
43
+  }
44 44
 
45
-	public function password_verify($string) : bool
46
-	{
47
-		return password_verify($string, $this->password());
48
-	}
45
+  public function password_verify($string) : bool
46
+  {
47
+    return password_verify($string, $this->password());
48
+  }
49 49
 
50 50
   public function name()
51 51
   {
@@ -61,39 +61,39 @@  discard block
 block discarded – undo
61 61
     return $this->get('phone');
62 62
   }
63 63
 
64
-	public function language_code()
64
+  public function language_code()
65 65
   {
66 66
     return $this->get('language_code');
67 67
   }
68 68
 
69
-	public static function query_retrieve($filters=[], $options=[]) : Select
70
-	{
71
-		$Query = static::table()->select();
72
-  	if(isset($options['eager']) && $options['eager'] === true)
73
-		{
69
+  public static function query_retrieve($filters=[], $options=[]) : Select
70
+  {
71
+    $Query = static::table()->select();
72
+    if(isset($options['eager']) && $options['eager'] === true)
73
+    {
74 74
       $Query->group_by('id');
75 75
 
76 76
       $Query->auto_join([ACL::table(), 'acl'], null, 'LEFT OUTER');
77 77
       $Query->auto_join([Permission::table(), 'kadro_permission'], null, 'LEFT OUTER');
78
-			$Query->select_also(["GROUP_CONCAT(DISTINCT kadro_permission.id) as permission_ids", "GROUP_CONCAT(DISTINCT kadro_permission.name) as permission_names"]);
79
-		}
78
+      $Query->select_also(["GROUP_CONCAT(DISTINCT kadro_permission.id) as permission_ids", "GROUP_CONCAT(DISTINCT kadro_permission.name) as permission_names"]);
79
+    }
80 80
 
81
-		if(isset($filters['model']) && !empty($filters['model']))
82
-		{
83
-			$model = $filters['model'];
84
-			$Query->join([static::otm('t'), static::otm('a')],[[static::otm('a'),static::otm('k'), 't_from','id']], 'INNER');
85
-			$Query->aw_fields_eq(['model_id' => $filters['model']->get_id(), 'model_type' => get_class($filters['model'])::model_type()], static::otm('a'));
86
-		}
81
+    if(isset($filters['model']) && !empty($filters['model']))
82
+    {
83
+      $model = $filters['model'];
84
+      $Query->join([static::otm('t'), static::otm('a')],[[static::otm('a'),static::otm('k'), 't_from','id']], 'INNER');
85
+      $Query->aw_fields_eq(['model_id' => $filters['model']->get_id(), 'model_type' => get_class($filters['model'])::model_type()], static::otm('a'));
86
+    }
87 87
 
88 88
     $Query->order_by([$Query->table_label(), 'name', 'ASC']);
89 89
 
90 90
 
91
-		return $Query;
92
-	}
91
+    return $Query;
92
+  }
93 93
 
94
-	public function immortal() : bool
95
-	{
96
-		return true; // never delete a user, always deactivate
97
-	}
94
+  public function immortal() : bool
95
+  {
96
+    return true; // never delete a user, always deactivate
97
+  }
98 98
 }
99 99
 
Please login to merge, or discard this patch.
common.inc.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -2,153 +2,153 @@
 block discarded – undo
2 2
 
3 3
 namespace HexMakina\kadro
4 4
 {
5
-	use \HexMakina\LocalFS\FileSystem;
5
+  use \HexMakina\LocalFS\FileSystem;
6 6
 
7
-	define('KADRO_BASE', APP_BASE.'/lib/kadro/'); // this is project dependant, should be in settings
8
-	// define('QIVIVE_BASE', APP_BASE.'/lib/qivive/'); // this is project dependant, should be in settings
7
+  define('KADRO_BASE', APP_BASE.'/lib/kadro/'); // this is project dependant, should be in settings
8
+  // define('QIVIVE_BASE', APP_BASE.'/lib/qivive/'); // this is project dependant, should be in settings
9 9
 
10
-	set_include_path(implode(PATH_SEPARATOR, [get_include_path(), APP_BASE, APP_BASE.'/lib/', APP_BASE.'/vendor/', KADRO_BASE]));
10
+  set_include_path(implode(PATH_SEPARATOR, [get_include_path(), APP_BASE, APP_BASE.'/lib/', APP_BASE.'/vendor/', KADRO_BASE]));
11 11
 
12
-	//---------------------------------------------------------------     autoloader
12
+  //---------------------------------------------------------------     autoloader
13 13
   require APP_BASE.'vendor/autoload.php';
14 14
 
15
-	require 'PSR4Autoloader.class.php';
16
-	$loader=new PSR4Autoloader;
17
-	$loader->register(); //Register loader with SPL autoloader stack.
15
+  require 'PSR4Autoloader.class.php';
16
+  $loader=new PSR4Autoloader;
17
+  $loader->register(); //Register loader with SPL autoloader stack.
18 18
 
19
-	$loader->addNamespace('HexMakina', APP_BASE.'/lib/');
19
+  $loader->addNamespace('HexMakina', APP_BASE.'/lib/');
20 20
 
21
-	// $loader->addNamespace('HexMakina\Crudites', APP_BASE.'/lib/Crudites/');
22
-	// $loader->addNamespace('HexMakina\ORM', APP_BASE.'/lib/ORM/');
23
-	// $loader->addNamespace('HexMakina\Lezer', APP_BASE.'/lib/Lezer/');
24
-	// $loader->addNamespace('HexMakina\Format', APP_BASE.'/lib/Format');
21
+  // $loader->addNamespace('HexMakina\Crudites', APP_BASE.'/lib/Crudites/');
22
+  // $loader->addNamespace('HexMakina\ORM', APP_BASE.'/lib/ORM/');
23
+  // $loader->addNamespace('HexMakina\Lezer', APP_BASE.'/lib/Lezer/');
24
+  // $loader->addNamespace('HexMakina\Format', APP_BASE.'/lib/Format');
25 25
 
26
-	// $loader->addNamespace('HexMakina\kadro', KADRO_BASE);
27
-	// $loader->addNamespace('HexMakina\qivive', QIVIVE_BASE);
28
-	// $loader->addNamespace('HexMakina\LocalFS', __DIR__.'/Format/File');
29
-	$loader->addNamespaceTree(KADRO_BASE);
26
+  // $loader->addNamespace('HexMakina\kadro', KADRO_BASE);
27
+  // $loader->addNamespace('HexMakina\qivive', QIVIVE_BASE);
28
+  // $loader->addNamespace('HexMakina\LocalFS', __DIR__.'/Format/File');
29
+  $loader->addNamespaceTree(KADRO_BASE);
30 30
 
31
-	//---------------------------------------------------------------     erara raportado
32
-	error_reporting(E_ALL);
31
+  //---------------------------------------------------------------     erara raportado
32
+  error_reporting(E_ALL);
33 33
 
34
-	set_error_handler('\HexMakina\kadro\Logger\LogLaddy::error_handler');
35
-	set_exception_handler('\HexMakina\kadro\Logger\LogLaddy::exception_handler');
34
+  set_error_handler('\HexMakina\kadro\Logger\LogLaddy::error_handler');
35
+  set_exception_handler('\HexMakina\kadro\Logger\LogLaddy::exception_handler');
36 36
 
37
-	\HexMakina\Debugger\Debugger::init();
37
+  \HexMakina\Debugger\Debugger::init();
38 38
 
39
-	//---------------------------------------------------------------     parametroj
40
-	require_once APP_BASE.'configs/settings.php';
41
-	$box=new Container\LeMarchand($settings);
39
+  //---------------------------------------------------------------     parametroj
40
+  require_once APP_BASE.'configs/settings.php';
41
+  $box=new Container\LeMarchand($settings);
42 42
 
43 43
   foreach($box->get('settings.app.namespaces') as $namespace => $path)
44 44
   {
45
-  	$loader->addNamespace($namespace, $path);
45
+    $loader->addNamespace($namespace, $path);
46 46
   }
47 47
 
48
-	define('PRODUCTION', $_SERVER['HTTP_HOST'] === $box->get('settings.app.production_host'));
49
-	ini_set('display_errors', PRODUCTION ? 0 : 1);
48
+  define('PRODUCTION', $_SERVER['HTTP_HOST'] === $box->get('settings.app.production_host'));
49
+  ini_set('display_errors', PRODUCTION ? 0 : 1);
50 50
 
51
-	//---------------------------------------------------------------       logger
52
-	$box->register('LoggerInterface', new Logger\LogLaddy());
51
+  //---------------------------------------------------------------       logger
52
+  $box->register('LoggerInterface', new Logger\LogLaddy());
53 53
 
54
-	//---------------------------------------------------------------       router
55
-	$box->register('RouterInterface', new Router\hopper($box->get('settings.RouterInterface')));
54
+  //---------------------------------------------------------------       router
55
+  $box->register('RouterInterface', new Router\hopper($box->get('settings.RouterInterface')));
56 56
 
57
-	//---------------------------------------------------------------        kuketoj
58
-	setcookie('cookie_test', 'test_value', time()+(365 * 24 * 60 * 60), "/", "");
59
-	$cookies_enabled=isset($_COOKIE['cookie_test']); // houston, do we have cookies ?
57
+  //---------------------------------------------------------------        kuketoj
58
+  setcookie('cookie_test', 'test_value', time()+(365 * 24 * 60 * 60), "/", "");
59
+  $cookies_enabled=isset($_COOKIE['cookie_test']); // houston, do we have cookies ?
60 60
 
61
-	if($cookies_enabled === false)
62
-	{
63
-		ini_set('session.use_cookies', 0);
64
-		ini_set('session.use_only_cookies', 0);
65
-		ini_set('session.use_trans_sid', 1);
66
-		ini_set('session.cache_limiter', 'nocache');
67
-	}
61
+  if($cookies_enabled === false)
62
+  {
63
+    ini_set('session.use_cookies', 0);
64
+    ini_set('session.use_only_cookies', 0);
65
+    ini_set('session.use_trans_sid', 1);
66
+    ini_set('session.cache_limiter', 'nocache');
67
+  }
68 68
 
69 69
 //---------------------------------------------------------------        Session Management
70
-	$StateAgent=new StateAgent($box->get('settings.app.session_start_options') ?? []);
71
-	$StateAgent->add_runtime_filters((array)$box->get('settings.filter'));
72
-	$StateAgent->add_runtime_filters((array)($_SESSION['filter'] ?? []));
73
-	$StateAgent->add_runtime_filters((array)($_REQUEST['filter'] ?? []));
70
+  $StateAgent=new StateAgent($box->get('settings.app.session_start_options') ?? []);
71
+  $StateAgent->add_runtime_filters((array)$box->get('settings.filter'));
72
+  $StateAgent->add_runtime_filters((array)($_SESSION['filter'] ?? []));
73
+  $StateAgent->add_runtime_filters((array)($_REQUEST['filter'] ?? []));
74 74
 
75
-	$box->register('StateAgent', $StateAgent);
75
+  $box->register('StateAgent', $StateAgent);
76 76
 
77 77
 
78
-	//---------------------------------------------------------------     parametroj:signo
78
+  //---------------------------------------------------------------     parametroj:signo
79 79
 
80
-	ini_set('default_charset', $box->get('settings.default.charset'));
81
-	header('Content-type: text/html; charset='.strtolower($box->get('settings.default.charset')));
80
+  ini_set('default_charset', $box->get('settings.default.charset'));
81
+  header('Content-type: text/html; charset='.strtolower($box->get('settings.default.charset')));
82 82
 
83
-	//---------------------------------------------------------------     parametroj:linguo
84
-	putenv('LANG='.$box->get('settings.default.language'));
85
-	setlocale(LC_ALL, $box->get('settings.default.language'));
83
+  //---------------------------------------------------------------     parametroj:linguo
84
+  putenv('LANG='.$box->get('settings.default.language'));
85
+  setlocale(LC_ALL, $box->get('settings.default.language'));
86 86
 
87
-	//---------------------------------------------------------------     parametroj:datoj
88
-	date_default_timezone_set($box->get('settings.default.timezone'));
87
+  //---------------------------------------------------------------     parametroj:datoj
88
+  date_default_timezone_set($box->get('settings.default.timezone'));
89 89
 
90 90
 
91
-	//---------------------------------------------------------------     ŝablonoj
92
-	require_once 'smarty/smarty/libs/Smarty.class.php';
93
-	// Load smarty template parser
94
-	if(is_null($box->get('settings.smarty.template_path')) || is_null($box->get('settings.smarty.compiled_path')))
95
-			throw new \Exception("SMARTY CONFIG ERROR: missing parameters");
91
+  //---------------------------------------------------------------     ŝablonoj
92
+  require_once 'smarty/smarty/libs/Smarty.class.php';
93
+  // Load smarty template parser
94
+  if(is_null($box->get('settings.smarty.template_path')) || is_null($box->get('settings.smarty.compiled_path')))
95
+      throw new \Exception("SMARTY CONFIG ERROR: missing parameters");
96 96
 
97
-	$smarty=new \Smarty();
98
-	$box->register('template_engine', $smarty);
97
+  $smarty=new \Smarty();
98
+  $box->register('template_engine', $smarty);
99 99
 
100
-	$smarty->setTemplateDir($box->get('RouterInterface')->file_root() . $box->get('settings.smarty.template_path').'app');
101
-	$smarty->addTemplateDir($box->get('RouterInterface')->file_root() . $box->get('settings.smarty.template_path'));
102
-	$smarty->addTemplateDir(KADRO_BASE . 'Views/');
100
+  $smarty->setTemplateDir($box->get('RouterInterface')->file_root() . $box->get('settings.smarty.template_path').'app');
101
+  $smarty->addTemplateDir($box->get('RouterInterface')->file_root() . $box->get('settings.smarty.template_path'));
102
+  $smarty->addTemplateDir(KADRO_BASE . 'Views/');
103 103
 
104
-	$smarty->setCompileDir(APP_BASE . $box->get('settings.smarty.compiled_path'));
105
-	$smarty->setDebugging($box->get('settings.smarty.debug'));
104
+  $smarty->setCompileDir(APP_BASE . $box->get('settings.smarty.compiled_path'));
105
+  $smarty->setDebugging($box->get('settings.smarty.debug'));
106 106
 
107
-	$smarty->registerClass('Lezer', 			'\HexMakina\Lezer\Lezer');
108
-	$smarty->registerClass('Marker', 			'\HexMakina\Format\HTML\Marker');
109
-	$smarty->registerClass('Form', 				'\HexMakina\Format\HTML\Form');
110
-	$smarty->registerClass('TableToForm',	'\HexMakina\kadro\TableToForm');
111
-	$smarty->registerClass('Dato', 				'\HexMakina\Format\Tempo\Dato');
107
+  $smarty->registerClass('Lezer', 			'\HexMakina\Lezer\Lezer');
108
+  $smarty->registerClass('Marker', 			'\HexMakina\Format\HTML\Marker');
109
+  $smarty->registerClass('Form', 				'\HexMakina\Format\HTML\Form');
110
+  $smarty->registerClass('TableToForm',	'\HexMakina\kadro\TableToForm');
111
+  $smarty->registerClass('Dato', 				'\HexMakina\Format\Tempo\Dato');
112 112
 
113
-	$smarty->assign('APP_NAME', $box->get('settings.app.name'));
113
+  $smarty->assign('APP_NAME', $box->get('settings.app.name'));
114 114
 
115
-	//---------------------------------------------------------------     lingva
115
+  //---------------------------------------------------------------     lingva
116 116
 
117
-	$languages=\HexMakina\Lezer\Lezer::languages_by_file(APP_BASE.'locale/');
117
+  $languages=\HexMakina\Lezer\Lezer::languages_by_file(APP_BASE.'locale/');
118 118
 
119 119
   $smarty->assign('languages', $languages);
120 120
 
121
-	$language=null;
122
-
123
-	// changing / setting the language
124
-	if(isset($_GET['lang']))
125
-	{
126
-		if(isset($languages[$_GET['lang']]))
127
-		{
128
-			$language=$_GET['lang'];
129
-			if($cookies_enabled === true)
130
-				setcookie('lang', $language, time()+(365 * 24 * 60 * 60), "/", "");
131
-			else
132
-				trigger_error('KADRO_SYSTEM_ERR_COOKIES_ARE_DISABLED_LANGUAGE_CANNOT_BE_STORED', E_USER_WARNING);
133
-		}
134
-		else
135
-			throw new \Exception('KADRO_SYSTEM_ERR_INVALID_PARAMETER');
136
-	}
137
-	else if($cookies_enabled === true && array_key_exists('lang', $_COOKIE) && array_key_exists($_COOKIE['lang'], $languages))
138
-		$language=$_COOKIE['lang'];
139
-
140
-	if(is_null($language) && !empty($languages))
141
-	{
142
-		if(count($languages) === 1)
143
-			$language=key($languages);
144
-		elseif(array_key_exists($box->get('settings.default.language'), $languages))
145
-			$language=$box->get('settings.default.language');
146
-		else
147
-			throw new \Exception('FALLBACK_TO_DEFAULT_LANGUAGE_FAILED');
148
-		$i18n = new \HexMakina\Lezer\Lezer(APP_BASE.'locale/'.$language.'/user_interface.json', APP_BASE.'locale/cache/', $language);
149
-		$i18n->init();
150
-		$smarty->assign('language', $language);
151
-	}
121
+  $language=null;
122
+
123
+  // changing / setting the language
124
+  if(isset($_GET['lang']))
125
+  {
126
+    if(isset($languages[$_GET['lang']]))
127
+    {
128
+      $language=$_GET['lang'];
129
+      if($cookies_enabled === true)
130
+        setcookie('lang', $language, time()+(365 * 24 * 60 * 60), "/", "");
131
+      else
132
+        trigger_error('KADRO_SYSTEM_ERR_COOKIES_ARE_DISABLED_LANGUAGE_CANNOT_BE_STORED', E_USER_WARNING);
133
+    }
134
+    else
135
+      throw new \Exception('KADRO_SYSTEM_ERR_INVALID_PARAMETER');
136
+  }
137
+  else if($cookies_enabled === true && array_key_exists('lang', $_COOKIE) && array_key_exists($_COOKIE['lang'], $languages))
138
+    $language=$_COOKIE['lang'];
139
+
140
+  if(is_null($language) && !empty($languages))
141
+  {
142
+    if(count($languages) === 1)
143
+      $language=key($languages);
144
+    elseif(array_key_exists($box->get('settings.default.language'), $languages))
145
+      $language=$box->get('settings.default.language');
146
+    else
147
+      throw new \Exception('FALLBACK_TO_DEFAULT_LANGUAGE_FAILED');
148
+    $i18n = new \HexMakina\Lezer\Lezer(APP_BASE.'locale/'.$language.'/user_interface.json', APP_BASE.'locale/cache/', $language);
149
+    $i18n->init();
150
+    $smarty->assign('language', $language);
151
+  }
152 152
 }
153 153
 
154 154
 
Please login to merge, or discard this patch.
Controllers/Interfaces/CRUDController.class.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,14 +4,14 @@
 block discarded – undo
4 4
 
5 5
 interface CRUDController
6 6
 {
7
-   public function dashboard();
8
-   public function edit();
9
-   public function save();
10
-   public function listing();
7
+    public function dashboard();
8
+    public function edit();
9
+    public function save();
10
+    public function listing();
11 11
 
12
-   public function destroy();
12
+    public function destroy();
13 13
 
14
-   public function errors() : array;
14
+    public function errors() : array;
15 15
 }
16 16
 
17 17
 
Please login to merge, or discard this patch.
Controllers/ORMController.class.php 2 patches
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
     $custom_template = null;
28 28
     $method = $this->router()->target_method();
29 29
 
30
-    foreach(['prepare', "before_$method", $method, "after_$method"] as $step => $chainling)
30
+    foreach (['prepare', "before_$method", $method, "after_$method"] as $step => $chainling)
31 31
     {
32 32
       $this->search_and_execute_trait_methods($chainling);
33
-    	if(method_exists($this, $chainling) && empty($this->errors()))
33
+    	if (method_exists($this, $chainling) && empty($this->errors()))
34 34
       {
35 35
         $res = $this->$chainling();
36 36
 
37
-        if($this->logger()->has_halting_messages()) // logger handled a critical error during the chailing execution
37
+        if ($this->logger()->has_halting_messages()) // logger handled a critical error during the chailing execution
38 38
         {
39 39
           break; // dont go on with other
40 40
         }
41 41
 
42
-        if($chainling === $method)
42
+        if ($chainling === $method)
43 43
         {
44 44
 
45 45
           $custom_template = $res;
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
       }
48 48
     }
49 49
 
50
-    if(method_exists($this, 'conclude')) // conclude always executed, even with has_halting_messages
50
+    if (method_exists($this, 'conclude')) // conclude always executed, even with has_halting_messages
51 51
     	$this->conclude();
52 52
 
53
-    if(method_exists($this, 'display'))
53
+    if (method_exists($this, 'display'))
54 54
     	$template = $this->display($custom_template);
55 55
   }
56 56
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
   {
59 59
     parent::prepare();
60 60
 
61
-    if(!class_exists($this->model_class_name = $this->class_name()))
61
+    if (!class_exists($this->model_class_name = $this->class_name()))
62 62
       throw new \Exception("!class_exists($this->model_class_name)");
63 63
 
64 64
     $this->model_type = $this->model_class_name::model_type();
@@ -68,22 +68,22 @@  discard block
 block discarded – undo
68 68
 
69 69
     $pk_values = [];
70 70
 
71
-    if($this->router()->submits())
71
+    if ($this->router()->submits())
72 72
     {
73 73
       $this->form_model->import($this->sanitize_post_data($this->router()->submitted()));
74 74
       $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->submitted());
75 75
 
76 76
       $this->load_model = $this->model_class_name::exists($pk_values);
77 77
     }
78
-    elseif($this->router()->requests())
78
+    elseif ($this->router()->requests())
79 79
     {
80 80
       $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->params());
81 81
 
82
-      if(!is_null($this->load_model = $this->model_class_name::exists($pk_values)))
82
+      if (!is_null($this->load_model = $this->model_class_name::exists($pk_values)))
83 83
         $this->form_model = clone $this->load_model;
84 84
     }
85 85
 
86
-    if(!is_null($this->load_model) && $this->load_model->traceable())
86
+    if (!is_null($this->load_model) && $this->load_model->traceable())
87 87
       $this->viewport('load_model_history', $this->load_model->traces() ?? []);
88 88
   }
89 89
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
   // ----------- META -----------
95 95
   public function class_name() : string
96 96
   {
97
-    if(is_null($this->model_class_name))
97
+    if (is_null($this->model_class_name))
98 98
     {
99 99
       $this->model_class_name = get_called_class();
100 100
       $this->model_class_name = str_replace('\Controllers\\', '\Models\\', $this->model_class_name);
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
   public function persist_model($model) : ?ModelInterface
108 108
   {
109 109
     $this->errors = $model->save($this->operator()->operator_id(), $this->tracer()); // returns [errors]
110
-    if(empty($this->errors()))
110
+    if (empty($this->errors()))
111 111
     {
112 112
       $this->logger()->nice('CRUDITES_INSTANCE_ALTERED', ['MODEL_'.get_class($model)::model_type().'_INSTANCE']);
113 113
       return $model;
114 114
     }
115
-    foreach($this->errors() as $field => $error_msg)
115
+    foreach ($this->errors() as $field => $error_msg)
116 116
       $this->logger()->warning($error_msg, [$field]);
117 117
 
118 118
     return null;
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
     return $this->listing(); //default dashboard is a listing
124 124
   }
125 125
 
126
-  public function listing($model=null,$filters=[],$options=[])
126
+  public function listing($model = null, $filters = [], $options = [])
127 127
   {
128 128
     $class_name = is_null($model) ? $this->model_class_name : get_class($model);
129 129
 
130
-    if(!isset($filters['date_start']))  $filters['date_start'] = $this->box('StateAgent')->filters('date_start');
131
-    if(!isset($filters['date_stop']))   $filters['date_stop'] = $this->box('StateAgent')->filters('date_stop');
130
+    if (!isset($filters['date_start']))  $filters['date_start'] = $this->box('StateAgent')->filters('date_start');
131
+    if (!isset($filters['date_stop']))   $filters['date_stop'] = $this->box('StateAgent')->filters('date_stop');
132 132
 
133 133
     // dd($filters);
134 134
     $listing = $class_name::filter($filters);
@@ -139,24 +139,24 @@  discard block
 block discarded – undo
139 139
   public function viewport_listing($class_name, $listing, $listing_template)
140 140
   {
141 141
     $listing_fields = [];
142
-    if(empty($listing))
142
+    if (empty($listing))
143 143
     {
144
-      foreach($class_name::table()->columns() as $column)
144
+      foreach ($class_name::table()->columns() as $column)
145 145
       {
146 146
 
147
-        if(!$column->is_auto_incremented() && !$column->is_hidden())
148
-          $listing_fields[$column->name()]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $column->name()));
147
+        if (!$column->is_auto_incremented() && !$column->is_hidden())
148
+          $listing_fields[$column->name()] = L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $column->name()));
149 149
       }
150 150
     }
151 151
     else
152 152
     {
153 153
       $current = current($listing);
154
-      if(is_object($current))
154
+      if (is_object($current))
155 155
         $current = get_object_vars($current);
156 156
 
157
-      foreach(array_keys($current) as $field)
157
+      foreach (array_keys($current) as $field)
158 158
       {
159
-        $listing_fields[$field]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $field));
159
+        $listing_fields[$field] = L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $field));
160 160
       }
161 161
 
162 162
     }
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
     $this->edit();
179 179
   }
180 180
 
181
-  public function edit(){}
181
+  public function edit() {}
182 182
 
183 183
   public function save()
184 184
   {
185 185
     $model = $this->persist_model($this->form_model);
186 186
 
187
-    if(empty($this->errors()))
187
+    if (empty($this->errors()))
188 188
       $this->route_back($model);
189 189
     else
190 190
     {
@@ -195,21 +195,21 @@  discard block
 block discarded – undo
195 195
 
196 196
   public function before_edit()
197 197
   {
198
-    if(!is_null($this->router()->params('id')) && is_null($this->load_model))
198
+    if (!is_null($this->router()->params('id')) && is_null($this->load_model))
199 199
     {
200 200
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_NOT_FOUND', ['MODEL_'.$this->model_class_name::model_type().'_INSTANCE']);
201 201
       $this->router()->hop($this->model_class_name::model_type());
202 202
     }
203 203
   }
204 204
 
205
-  public function before_save() : array { return [];}
205
+  public function before_save() : array { return []; }
206 206
 
207 207
   // default: hop to altered object
208
-  public function after_save() {$this->router()->hop($this->route_back());}
208
+  public function after_save() {$this->router()->hop($this->route_back()); }
209 209
 
210 210
   public function destroy_confirm()
211 211
   {
212
-    if(is_null($this->load_model))
212
+    if (is_null($this->load_model))
213 213
     {
214 214
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_NOT_FOUND', ['MODEL_'.$this->model_type.'_INSTANCE']);
215 215
       $this->router()->hop($this->model_type);
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 
223 223
   public function before_destroy() // default: checks for load_model and immortality, hops back to object on failure
224 224
   {
225
-    if(is_null($this->load_model))
225
+    if (is_null($this->load_model))
226 226
     {
227 227
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_NOT_FOUND', ['MODEL_'.$this->model_type.'_INSTANCE']);
228 228
       $this->router()->hop($this->model_type);
229 229
     }
230
-    elseif($this->load_model->immortal())
230
+    elseif ($this->load_model->immortal())
231 231
     {
232 232
 
233 233
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', ['MODEL_'.$this->model_type.'_INSTANCE']);
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
 
238 238
   public function destroy()
239 239
   {
240
-    if(!$this->router()->submits())
240
+    if (!$this->router()->submits())
241 241
       throw new \Exception('KADRO_ROUTER_MUST_SUBMIT');
242 242
 
243
-    if($this->load_model->destroy($this->operator()->operator_id(), $this->tracer()) === false)
243
+    if ($this->load_model->destroy($this->operator()->operator_id(), $this->tracer()) === false)
244 244
     {
245 245
       $this->logger()->info('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', [''.$this->load_model]);
246 246
       $this->route_back($this->load_model);
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 
264 264
     $this->viewport('form_model_type', $this->model_type);
265 265
 
266
-    if(isset($this->load_model))
266
+    if (isset($this->load_model))
267 267
       $this->viewport('load_model', $this->load_model);
268 268
 
269
-    if(isset($this->form_model))
269
+    if (isset($this->form_model))
270 270
       $this->viewport('form_model', $this->form_model);
271 271
   }
272 272
 
@@ -278,15 +278,15 @@  discard block
 block discarded – undo
278 278
 
279 279
     $header = false;
280 280
 
281
-    foreach($collection as $line)
281
+    foreach ($collection as $line)
282 282
     {
283 283
       $line = get_object_vars($line);
284
-      if($header === false)
284
+      if ($header === false)
285 285
       {
286
-        fputcsv($fp,array_keys($line));
286
+        fputcsv($fp, array_keys($line));
287 287
         $header = true;
288 288
       }
289
-      fputcsv($fp,$line);
289
+      fputcsv($fp, $line);
290 290
     }
291 291
     fclose($fp);
292 292
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
   public function export()
297 297
   {
298 298
     $format = $this->router()->params('format');
299
-    switch($format)
299
+    switch ($format)
300 300
     {
301 301
       case null:
302 302
         $filename = $this->model_type;
@@ -325,33 +325,33 @@  discard block
 block discarded – undo
325 325
     $route_params = [];
326 326
 
327 327
     $route_name = get_class($model)::model_type().'_';
328
-    if($model->is_new())
329
-      $route_name.= 'new';
328
+    if ($model->is_new())
329
+      $route_name .= 'new';
330 330
     else
331 331
     {
332
-      $route_name.= 'default';
332
+      $route_name .= 'default';
333 333
       $route_params = ['id' => $model->get_id()];
334 334
     }
335 335
     $res = $this->router()->prehop($route_name, $route_params);
336 336
     return $res;
337 337
   }
338 338
 
339
-  public function route_factory($route=null, $route_params=[]) : string
339
+  public function route_factory($route = null, $route_params = []) : string
340 340
   {
341
-    if(is_null($route) && $this->router()->submits())
341
+    if (is_null($route) && $this->router()->submits())
342 342
       $route = $this->form_model;
343 343
 
344
-    if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface'))
344
+    if (!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface'))
345 345
       $route = $this->route_model($route);
346 346
 
347 347
     return parent::route_factory($route, $route_params);
348 348
   }
349 349
 
350
-  private function sanitize_post_data($post_data=[])
350
+  private function sanitize_post_data($post_data = [])
351 351
   {
352
-    foreach($this->model_class_name::table()->columns() as $col)
352
+    foreach ($this->model_class_name::table()->columns() as $col)
353 353
     {
354
-      if($col->type()->is_boolean())
354
+      if ($col->type()->is_boolean())
355 355
       {
356 356
           $post_data[$col->name()] = !empty($post_data[$col->name()]);
357 357
       }
Please login to merge, or discard this patch.
Braces   +60 added lines, -43 removed lines patch added patch discarded remove patch
@@ -34,9 +34,12 @@  discard block
 block discarded – undo
34 34
       {
35 35
         $res = $this->$chainling();
36 36
 
37
-        if($this->logger()->has_halting_messages()) // logger handled a critical error during the chailing execution
37
+        if($this->logger()->has_halting_messages()) {
38
+          // logger handled a critical error during the chailing execution
38 39
         {
39
-          break; // dont go on with other
40
+          break;
41
+        }
42
+        // dont go on with other
40 43
         }
41 44
 
42 45
         if($chainling === $method)
@@ -47,19 +50,23 @@  discard block
 block discarded – undo
47 50
       }
48 51
     }
49 52
 
50
-    if(method_exists($this, 'conclude')) // conclude always executed, even with has_halting_messages
53
+    if(method_exists($this, 'conclude')) {
54
+      // conclude always executed, even with has_halting_messages
51 55
     	$this->conclude();
56
+    }
52 57
 
53
-    if(method_exists($this, 'display'))
54
-    	$template = $this->display($custom_template);
58
+    if(method_exists($this, 'display')) {
59
+        	$template = $this->display($custom_template);
60
+    }
55 61
   }
56 62
 
57 63
   public function prepare()
58 64
   {
59 65
     parent::prepare();
60 66
 
61
-    if(!class_exists($this->model_class_name = $this->class_name()))
62
-      throw new \Exception("!class_exists($this->model_class_name)");
67
+    if(!class_exists($this->model_class_name = $this->class_name())) {
68
+          throw new \Exception("!class_exists($this->model_class_name)");
69
+    }
63 70
 
64 71
     $this->model_type = $this->model_class_name::model_type();
65 72
 
@@ -74,17 +81,18 @@  discard block
 block discarded – undo
74 81
       $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->submitted());
75 82
 
76 83
       $this->load_model = $this->model_class_name::exists($pk_values);
77
-    }
78
-    elseif($this->router()->requests())
84
+    } elseif($this->router()->requests())
79 85
     {
80 86
       $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->params());
81 87
 
82
-      if(!is_null($this->load_model = $this->model_class_name::exists($pk_values)))
83
-        $this->form_model = clone $this->load_model;
88
+      if(!is_null($this->load_model = $this->model_class_name::exists($pk_values))) {
89
+              $this->form_model = clone $this->load_model;
90
+      }
84 91
     }
85 92
 
86
-    if(!is_null($this->load_model) && $this->load_model->traceable())
87
-      $this->viewport('load_model_history', $this->load_model->traces() ?? []);
93
+    if(!is_null($this->load_model) && $this->load_model->traceable()) {
94
+          $this->viewport('load_model_history', $this->load_model->traces() ?? []);
95
+    }
88 96
   }
89 97
 
90 98
   public function has_load_model()
@@ -112,8 +120,9 @@  discard block
 block discarded – undo
112 120
       $this->logger()->nice('CRUDITES_INSTANCE_ALTERED', ['MODEL_'.get_class($model)::model_type().'_INSTANCE']);
113 121
       return $model;
114 122
     }
115
-    foreach($this->errors() as $field => $error_msg)
116
-      $this->logger()->warning($error_msg, [$field]);
123
+    foreach($this->errors() as $field => $error_msg) {
124
+          $this->logger()->warning($error_msg, [$field]);
125
+    }
117 126
 
118 127
     return null;
119 128
   }
@@ -127,8 +136,12 @@  discard block
 block discarded – undo
127 136
   {
128 137
     $class_name = is_null($model) ? $this->model_class_name : get_class($model);
129 138
 
130
-    if(!isset($filters['date_start']))  $filters['date_start'] = $this->box('StateAgent')->filters('date_start');
131
-    if(!isset($filters['date_stop']))   $filters['date_stop'] = $this->box('StateAgent')->filters('date_stop');
139
+    if(!isset($filters['date_start'])) {
140
+      $filters['date_start'] = $this->box('StateAgent')->filters('date_start');
141
+    }
142
+    if(!isset($filters['date_stop'])) {
143
+      $filters['date_stop'] = $this->box('StateAgent')->filters('date_stop');
144
+    }
132 145
 
133 146
     // dd($filters);
134 147
     $listing = $class_name::filter($filters);
@@ -144,15 +157,16 @@  discard block
 block discarded – undo
144 157
       foreach($class_name::table()->columns() as $column)
145 158
       {
146 159
 
147
-        if(!$column->is_auto_incremented() && !$column->is_hidden())
148
-          $listing_fields[$column->name()]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $column->name()));
160
+        if(!$column->is_auto_incremented() && !$column->is_hidden()) {
161
+                  $listing_fields[$column->name()]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $column->name()));
162
+        }
149 163
       }
150
-    }
151
-    else
164
+    } else
152 165
     {
153 166
       $current = current($listing);
154
-      if(is_object($current))
155
-        $current = get_object_vars($current);
167
+      if(is_object($current)) {
168
+              $current = get_object_vars($current);
169
+      }
156 170
 
157 171
       foreach(array_keys($current) as $field)
158 172
       {
@@ -184,9 +198,9 @@  discard block
 block discarded – undo
184 198
   {
185 199
     $model = $this->persist_model($this->form_model);
186 200
 
187
-    if(empty($this->errors()))
188
-      $this->route_back($model);
189
-    else
201
+    if(empty($this->errors())) {
202
+          $this->route_back($model);
203
+    } else
190 204
     {
191 205
       $this->edit();
192 206
       return 'edit';
@@ -226,8 +240,7 @@  discard block
 block discarded – undo
226 240
     {
227 241
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_NOT_FOUND', ['MODEL_'.$this->model_type.'_INSTANCE']);
228 242
       $this->router()->hop($this->model_type);
229
-    }
230
-    elseif($this->load_model->immortal())
243
+    } elseif($this->load_model->immortal())
231 244
     {
232 245
 
233 246
       $this->logger()->warning('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', ['MODEL_'.$this->model_type.'_INSTANCE']);
@@ -237,15 +250,15 @@  discard block
 block discarded – undo
237 250
 
238 251
   public function destroy()
239 252
   {
240
-    if(!$this->router()->submits())
241
-      throw new \Exception('KADRO_ROUTER_MUST_SUBMIT');
253
+    if(!$this->router()->submits()) {
254
+          throw new \Exception('KADRO_ROUTER_MUST_SUBMIT');
255
+    }
242 256
 
243 257
     if($this->load_model->destroy($this->operator()->operator_id(), $this->tracer()) === false)
244 258
     {
245 259
       $this->logger()->info('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', [''.$this->load_model]);
246 260
       $this->route_back($this->load_model);
247
-    }
248
-    else
261
+    } else
249 262
     {
250 263
       $this->logger()->nice('CRUDITES_INSTANCE_DESTROYED', ['MODEL_'.$this->model_type.'_INSTANCE']);
251 264
       $this->route_back($this->model_type);
@@ -263,11 +276,13 @@  discard block
 block discarded – undo
263 276
 
264 277
     $this->viewport('form_model_type', $this->model_type);
265 278
 
266
-    if(isset($this->load_model))
267
-      $this->viewport('load_model', $this->load_model);
279
+    if(isset($this->load_model)) {
280
+          $this->viewport('load_model', $this->load_model);
281
+    }
268 282
 
269
-    if(isset($this->form_model))
270
-      $this->viewport('form_model', $this->form_model);
283
+    if(isset($this->form_model)) {
284
+          $this->viewport('form_model', $this->form_model);
285
+    }
271 286
   }
272 287
 
273 288
   public function collection_to_csv($collection, $filename)
@@ -325,9 +340,9 @@  discard block
 block discarded – undo
325 340
     $route_params = [];
326 341
 
327 342
     $route_name = get_class($model)::model_type().'_';
328
-    if($model->is_new())
329
-      $route_name.= 'new';
330
-    else
343
+    if($model->is_new()) {
344
+          $route_name.= 'new';
345
+    } else
331 346
     {
332 347
       $route_name.= 'default';
333 348
       $route_params = ['id' => $model->get_id()];
@@ -338,11 +353,13 @@  discard block
 block discarded – undo
338 353
 
339 354
   public function route_factory($route=null, $route_params=[]) : string
340 355
   {
341
-    if(is_null($route) && $this->router()->submits())
342
-      $route = $this->form_model;
356
+    if(is_null($route) && $this->router()->submits()) {
357
+          $route = $this->form_model;
358
+    }
343 359
 
344
-    if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface'))
345
-      $route = $this->route_model($route);
360
+    if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface')) {
361
+          $route = $this->route_model($route);
362
+    }
346 363
 
347 364
     return parent::route_factory($route, $route_params);
348 365
   }
Please login to merge, or discard this patch.
Logger/LogLaddy.class.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
     $context['class'] = get_class($throwable);
55 55
     $context['trace'] = $throwable->getTrace();
56 56
 
57
-    if(is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error')
57
+    if (is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error')
58 58
       (new LogLaddy())->alert(self::INTERNAL_ERROR, $context);
59
-    elseif(is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception')
59
+    elseif (is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception')
60 60
       (new LogLaddy())->notice(self::USER_EXCEPTION, $context);
61 61
     else
62 62
     {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
   public function system_halted($level)
69 69
   {
70
-    switch($level)
70
+    switch ($level)
71 71
     {
72 72
       case LogLevel::ERROR:
73 73
       case LogLevel::CRITICAL:
@@ -86,19 +86,19 @@  discard block
 block discarded – undo
86 86
     $display_error = null;
87 87
 
88 88
     // --- Handles Throwables (exception_handler())
89
-    if($message==self::INTERNAL_ERROR || $message== self::USER_EXCEPTION)
89
+    if ($message == self::INTERNAL_ERROR || $message == self::USER_EXCEPTION)
90 90
     {
91 91
       $this->has_halting_messages = true;
92 92
       $display_error = \HexMakina\Debugger\Debugger::format_throwable_message($context['class'], $context['code'], $context['file'], $context['line'], $context['text']);
93 93
       error_log($display_error);
94
-      $display_error.= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false);
94
+      $display_error .= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false);
95 95
       self::HTTP_500($display_error);
96 96
     }
97
-    elseif($this->system_halted($level)) // analyses error level
97
+    elseif ($this->system_halted($level)) // analyses error level
98 98
     {
99 99
       $display_error = sprintf(PHP_EOL.'%s in file %s:%d'.PHP_EOL.'%s', $level, \HexMakina\Debugger\Debugger::format_file($context['file']), $context['line'], $message);
100 100
       error_log($display_error);
101
-      $display_error.= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false);
101
+      $display_error .= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false);
102 102
       self::HTTP_500($display_error);
103 103
     }
104 104
     else
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
   // ----------------------------------------------------------- User messages:add one
151 151
   public function report_to_user($level, $message, $context = [])
152 152
   {
153
-    if(!isset($_SESSION[self::REPORTING_USER]))
153
+    if (!isset($_SESSION[self::REPORTING_USER]))
154 154
       $_SESSION[self::REPORTING_USER] = [];
155 155
 
156
-    if(!isset($_SESSION[self::REPORTING_USER][$level]))
156
+    if (!isset($_SESSION[self::REPORTING_USER][$level]))
157 157
       $_SESSION[self::REPORTING_USER][$level] = [];
158 158
 
159 159
     $_SESSION[self::REPORTING_USER][$level][] = [$message, $context];
@@ -185,21 +185,21 @@  discard block
 block discarded – undo
185 185
   private static function map_error_level_to_log_level($level) : string
186 186
   {
187 187
     // http://php.net/manual/en/errorfunc.constants.php
188
-    $m=[];
188
+    $m = [];
189 189
 
190
-    $m[E_ERROR]=$m[E_PARSE]=$m[E_CORE_ERROR]=$m[E_COMPILE_ERROR]=$m[E_USER_ERROR]=$m[E_RECOVERABLE_ERROR]=LogLevel::ALERT;
191
-    $m[1]=$m[4]=$m[16]=$m[64]=$m[256]=$m[4096]=LogLevel::ALERT;
190
+    $m[E_ERROR] = $m[E_PARSE] = $m[E_CORE_ERROR] = $m[E_COMPILE_ERROR] = $m[E_USER_ERROR] = $m[E_RECOVERABLE_ERROR] = LogLevel::ALERT;
191
+    $m[1] = $m[4] = $m[16] = $m[64] = $m[256] = $m[4096] = LogLevel::ALERT;
192 192
 
193
-    $m[E_WARNING]=$m[E_CORE_WARNING]=$m[E_COMPILE_WARNING]=$m[E_USER_WARNING]=LogLevel::CRITICAL;
194
-    $m[2]=$m[32]=$m[128]=$m[512]=LogLevel::CRITICAL;
193
+    $m[E_WARNING] = $m[E_CORE_WARNING] = $m[E_COMPILE_WARNING] = $m[E_USER_WARNING] = LogLevel::CRITICAL;
194
+    $m[2] = $m[32] = $m[128] = $m[512] = LogLevel::CRITICAL;
195 195
 
196
-    $m[E_NOTICE]=$m[E_USER_NOTICE]=LogLevel::ERROR;
197
-    $m[8]=$m[1024]=LogLevel::ERROR;
196
+    $m[E_NOTICE] = $m[E_USER_NOTICE] = LogLevel::ERROR;
197
+    $m[8] = $m[1024] = LogLevel::ERROR;
198 198
 
199
-    $m[E_STRICT]=$m[E_DEPRECATED]=$m[E_USER_DEPRECATED]=$m[E_ALL]=LogLevel::DEBUG;
200
-    $m[2048]=$m[8192]=$m[16384]=$m[32767]=LogLevel::DEBUG;
199
+    $m[E_STRICT] = $m[E_DEPRECATED] = $m[E_USER_DEPRECATED] = $m[E_ALL] = LogLevel::DEBUG;
200
+    $m[2048] = $m[8192] = $m[16384] = $m[32767] = LogLevel::DEBUG;
201 201
 
202
-    if(isset($m[$level]))
202
+    if (isset($m[$level]))
203 203
       return $m[$level];
204 204
 
205 205
     throw new \Exception(__FUNCTION__."($level): $level is unknown");
Please login to merge, or discard this patch.
Braces   +18 added lines, -15 removed lines patch added patch discarded remove patch
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
     $context['class'] = get_class($throwable);
55 55
     $context['trace'] = $throwable->getTrace();
56 56
 
57
-    if(is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error')
58
-      (new LogLaddy())->alert(self::INTERNAL_ERROR, $context);
59
-    elseif(is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception')
60
-      (new LogLaddy())->notice(self::USER_EXCEPTION, $context);
61
-    else
57
+    if(is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error') {
58
+          (new LogLaddy())->alert(self::INTERNAL_ERROR, $context);
59
+    } elseif(is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception') {
60
+          (new LogLaddy())->notice(self::USER_EXCEPTION, $context);
61
+    } else
62 62
     {
63 63
       die('This Throwable is not an Error or an Exception. This is unfortunate.');
64 64
     }
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
       error_log($display_error);
94 94
       $display_error.= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false);
95 95
       self::HTTP_500($display_error);
96
-    }
97
-    elseif($this->system_halted($level)) // analyses error level
96
+    } elseif($this->system_halted($level)) {
97
+      // analyses error level
98 98
     {
99 99
       $display_error = sprintf(PHP_EOL.'%s in file %s:%d'.PHP_EOL.'%s', $level, \HexMakina\Debugger\Debugger::format_file($context['file']), $context['line'], $message);
100
+    }
100 101
       error_log($display_error);
101 102
       $display_error.= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false);
102 103
       self::HTTP_500($display_error);
103
-    }
104
-    else
104
+    } else
105 105
     {// --- Handles user messages, through SESSION storage
106 106
       $this->report_to_user($level, $message, $context);
107 107
     }
@@ -150,11 +150,13 @@  discard block
 block discarded – undo
150 150
   // ----------------------------------------------------------- User messages:add one
151 151
   public function report_to_user($level, $message, $context = [])
152 152
   {
153
-    if(!isset($_SESSION[self::REPORTING_USER]))
154
-      $_SESSION[self::REPORTING_USER] = [];
153
+    if(!isset($_SESSION[self::REPORTING_USER])) {
154
+          $_SESSION[self::REPORTING_USER] = [];
155
+    }
155 156
 
156
-    if(!isset($_SESSION[self::REPORTING_USER][$level]))
157
-      $_SESSION[self::REPORTING_USER][$level] = [];
157
+    if(!isset($_SESSION[self::REPORTING_USER][$level])) {
158
+          $_SESSION[self::REPORTING_USER][$level] = [];
159
+    }
158 160
 
159 161
     $_SESSION[self::REPORTING_USER][$level][] = [$message, $context];
160 162
   }
@@ -199,8 +201,9 @@  discard block
 block discarded – undo
199 201
     $m[E_STRICT]=$m[E_DEPRECATED]=$m[E_USER_DEPRECATED]=$m[E_ALL]=LogLevel::DEBUG;
200 202
     $m[2048]=$m[8192]=$m[16384]=$m[32767]=LogLevel::DEBUG;
201 203
 
202
-    if(isset($m[$level]))
203
-      return $m[$level];
204
+    if(isset($m[$level])) {
205
+          return $m[$level];
206
+    }
204 207
 
205 208
     throw new \Exception(__FUNCTION__."($level): $level is unknown");
206 209
   }
Please login to merge, or discard this patch.