Test Setup Failed
Branch 1.0.0-dev (6506b5)
by nguereza
05:54
created
classes/views/home.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
     <meta name="description" content="A simple PHP framework using HMVC architecture">
9 9
     <meta name="author" content="Tony NGUEREZA">
10 10
     <title>TNH Framework</title>
11
-    <link href="<?php echo Assets::css('bootstrap.min');?>" rel="stylesheet" type = "text/css" >
12
-	<link href="<?php echo Assets::css('font-awesome.min');?>" rel="stylesheet" type = "text/css" >
13
-    <link href="<?php echo Assets::css('responsive');?>" rel="stylesheet" type = "text/css" >
14
-	<link rel="icon" href="<?php echo Assets::img('favicon.ico');?>">
11
+    <link href="<?php echo Assets::css('bootstrap.min'); ?>" rel="stylesheet" type = "text/css" >
12
+	<link href="<?php echo Assets::css('font-awesome.min'); ?>" rel="stylesheet" type = "text/css" >
13
+    <link href="<?php echo Assets::css('responsive'); ?>" rel="stylesheet" type = "text/css" >
14
+	<link rel="icon" href="<?php echo Assets::img('favicon.ico'); ?>">
15 15
 	<!--[if lt IE 9]>
16
-	<script src="<?php echo Assets::js('html5shiv');?>"></script>
17
-	<script src="<?php echo Assets::js('respond.min');?>"></script>
16
+	<script src="<?php echo Assets::js('html5shiv'); ?>"></script>
17
+	<script src="<?php echo Assets::js('respond.min'); ?>"></script>
18 18
     <![endif]-->
19 19
 	<style type = "text/css">
20 20
 		
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
 			<div class = "col-md-offset-2 col-md-8 col-md-offset-2">
29 29
 				<div class = "panel panel-primary">
30 30
 					<div class = "panel-heading">
31
-						<h2>Welcome on <?php echo TNH_NAME;?> v<?php echo TNH_VERSION;?></h2>
31
+						<h2>Welcome on <?php echo TNH_NAME; ?> v<?php echo TNH_VERSION; ?></h2>
32 32
 					</div>
33 33
 					<div class = "panel-body">
34
-						<img src = "<?php echo Assets::img('logo.png');?>" class = "img-responsive" style = "float:left;" />
34
+						<img src = "<?php echo Assets::img('logo.png'); ?>" class = "img-responsive" style = "float:left;" />
35 35
 						<h3>
36 36
 							A simple PHP framework using HMVC architecture
37 37
 						</h3>
38 38
 						<br />
39
-						<p><?php echo Html::a('https://github.com/tnhfw/tnh-fw', 'Framework on Github', array('class' => 'btn btn-default', 'target' => '_blank'));?></p>
39
+						<p><?php echo Html::a('https://github.com/tnhfw/tnh-fw', 'Framework on Github', array('class' => 'btn btn-default', 'target' => '_blank')); ?></p>
40 40
 					</div>
41 41
 				</div>
42 42
 				<div class = "panel panel-primary">
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 						<h2>Server information</h2>
45 45
 					</div>
46 46
 					<div class = "panel-body">
47
-						<h4>Running on : <b><?php echo php_uname();?></b></h4>
48
-						<h4>PHP server SAPI : <b><?php echo php_sapi_name();?></b></h4>
49
-						<h4>PHP Version : <b><?php echo phpversion();?></b></h4>
50
-						<h4>PHP Loaded extensions : (<?php echo count(get_loaded_extensions());?> extensions)</h4>
47
+						<h4>Running on : <b><?php echo php_uname(); ?></b></h4>
48
+						<h4>PHP server SAPI : <b><?php echo php_sapi_name(); ?></b></h4>
49
+						<h4>PHP Version : <b><?php echo phpversion(); ?></b></h4>
50
+						<h4>PHP Loaded extensions : (<?php echo count(get_loaded_extensions()); ?> extensions)</h4>
51 51
 							<table class = "table table-striped table-condensed table-bordered table-responsive">
52 52
 								<tr>
53 53
 									<th>Name</th>
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 								</tr>
56 56
 								<?php foreach (get_loaded_extensions() as $e):?>
57 57
 									<tr>
58
-										<td><?php echo $e;?></td>
59
-										<td><?php echo phpversion($e);?></td>
58
+										<td><?php echo $e; ?></td>
59
+										<td><?php echo phpversion($e); ?></td>
60 60
 									</tr>
61
-								<?php endforeach;?>
61
+								<?php endforeach; ?>
62 62
 							</table>
63 63
 					</div>
64 64
 				</div>
@@ -67,30 +67,30 @@  discard block
 block discarded – undo
67 67
 						<h2>Framework information</h2>
68 68
 					</div>
69 69
 					<div class = "panel-body">
70
-						<h4>Version : <b><?php echo TNH_VERSION;?></b></h4>
71
-						<h4>Required PHP version : <b>PHP >= <?php echo TNH_REQUIRED_PHP_MIN_VERSION;?>, PHP <= <?php echo TNH_REQUIRED_PHP_MAX_VERSION;?></b></h4>
72
-						<h4>Build date : <b><?php echo TNH_RELEASE_DATE;?></b></h4>
73
-						<h4>Author : <b><?php echo TNH_AUTHOR;?></b></h4>
74
-						<h4>Author E-mail : <b><?php echo TNH_AUTHOR_EMAIL;?></b></h4>
75
-						<h4>Loaded files : (<?php echo count(get_included_files());?> files)</h4>
70
+						<h4>Version : <b><?php echo TNH_VERSION; ?></b></h4>
71
+						<h4>Required PHP version : <b>PHP >= <?php echo TNH_REQUIRED_PHP_MIN_VERSION; ?>, PHP <= <?php echo TNH_REQUIRED_PHP_MAX_VERSION; ?></b></h4>
72
+						<h4>Build date : <b><?php echo TNH_RELEASE_DATE; ?></b></h4>
73
+						<h4>Author : <b><?php echo TNH_AUTHOR; ?></b></h4>
74
+						<h4>Author E-mail : <b><?php echo TNH_AUTHOR_EMAIL; ?></b></h4>
75
+						<h4>Loaded files : (<?php echo count(get_included_files()); ?> files)</h4>
76 76
 							<table class = "table table-striped table-condensed table-bordered table-responsive">
77 77
 								<tr>
78 78
 									<th>Path</th>
79 79
 									<th>File</th>
80 80
 								</tr>
81
-								<?php foreach(get_included_files() as $file):?>
81
+								<?php foreach (get_included_files() as $file):?>
82 82
 									<tr>
83
-										<td><?php echo $file;?></td>
84
-										<td><?php echo basename($file);?></td>
83
+										<td><?php echo $file; ?></td>
84
+										<td><?php echo basename($file); ?></td>
85 85
 									</tr>
86
-								<?php endforeach;?>
86
+								<?php endforeach; ?>
87 87
 							</table>
88 88
 					</div>
89 89
 				</div>
90 90
 			</div>
91 91
 		</div>
92 92
 	</div>
93
-	<script src="<?php echo Assets::js('jquery');?>"></script>
94
-	<script src="<?php echo Assets::js('bootstrap.min');?>"></script>
93
+	<script src="<?php echo Assets::js('jquery'); ?>"></script>
94
+	<script src="<?php echo Assets::js('bootstrap.min'); ?>"></script>
95 95
 	</body>
96 96
 </html>
Please login to merge, or discard this patch.
index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -243,7 +243,7 @@
 block discarded – undo
243 243
 			if (version_compare(PHP_VERSION, '5.3', '>=')) {
244 244
 				error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
245 245
 			}
246
-			else{
246
+			else {
247 247
 				error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
248 248
 			}
249 249
 		break;
Please login to merge, or discard this patch.
core/bootstrap.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	
43 43
 	//if the application is running in CLI mode $_SESSION global variable is not available
44
-	if(IS_CLI){
44
+	if (IS_CLI) {
45 45
 		$_SESSION = array();
46 46
 	}
47 47
 		
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * The Benchmark class
62 62
 	 */
63
-	$BENCHMARK =& class_loader('Benchmark');
63
+	$BENCHMARK = & class_loader('Benchmark');
64 64
 	
65 65
 	$BENCHMARK->mark('APP_EXECUTION_START');
66 66
 	
67 67
 	/**
68 68
     * instance of the Log class
69 69
     */
70
-    $LOGGER =& class_loader('Log', 'classes');
70
+    $LOGGER = & class_loader('Log', 'classes');
71 71
 
72 72
     $LOGGER->setLogger('ApplicationBootstrap');
73 73
 
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 	/**
77 77
 	* Verification of the PHP environment: minimum and maximum version
78 78
 	*/
79
-	if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')){
79
+	if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')) {
80 80
 		show_error('Your PHP Version [' . phpversion() . '] is less than [' . TNH_REQUIRED_PHP_MIN_VERSION . '], please install a new version or update your PHP to the latest.', 'PHP Error environment');	
81 81
 	}
82
-	else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){
82
+	else if (version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')) {
83 83
 		show_error('Your PHP Version [' . phpversion() . '] is greather than [' . TNH_REQUIRED_PHP_MAX_VERSION . '] please install a PHP version that is compatible.', 'PHP Error environment');	
84 84
 	}
85 85
 	$LOGGER->info('PHP version [' . phpversion() . '] is OK [REQUIRED MINIMUM: ' . TNH_REQUIRED_PHP_MIN_VERSION . ', REQUIRED MAXIMUM: ' . TNH_REQUIRED_PHP_MAX_VERSION . '], application can work without any issue');
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	
102 102
 	//if user have some composer packages
103 103
 	$LOGGER->debug('Check for composer autoload');
104
-	if(file_exists(VENDOR_PATH . 'autoload.php')){
104
+	if (file_exists(VENDOR_PATH . 'autoload.php')) {
105 105
 		$LOGGER->info('The composer autoload file exists include it');
106 106
 		require_once VENDOR_PATH . 'autoload.php';
107 107
 	}
108
-	else{
108
+	else {
109 109
 		$LOGGER->info('The composer autoload file does not exist skipping');
110 110
 	}
111 111
 	
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
 	 * Load the EventDispatcher class
121 121
 	 * @var EventDispatcher
122 122
 	 */
123
-	$DISPATCHER =& class_loader('EventDispatcher', 'classes');
123
+	$DISPATCHER = & class_loader('EventDispatcher', 'classes');
124 124
 
125 125
 	$BENCHMARK->mark('CONFIG_INIT_START');
126 126
 	/**
127 127
 	* Load configurations and using the 
128 128
 	* static method "init()" to initialize the Config class .
129 129
 	*/
130
-	$CONFIG =& class_loader('Config', 'classes');	
130
+	$CONFIG = & class_loader('Config', 'classes');	
131 131
 	$CONFIG->init();
132 132
 	$BENCHMARK->mark('CONFIG_INIT_END');
133 133
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	* Load modules and using the 
137 137
 	* static method "init()" to initialize the Module class.
138 138
 	*/
139
-	$MODULE =& class_loader('Module', 'classes');
139
+	$MODULE = & class_loader('Module', 'classes');
140 140
 	$MODULE->init();
141 141
 	$BENCHMARK->mark('MODULE_INIT_END');
142 142
 
@@ -155,34 +155,34 @@  discard block
 block discarded – undo
155 155
 	/**
156 156
 	* Loading Security class
157 157
 	*/
158
-	$SECURITY =& class_loader('Security', 'classes');
158
+	$SECURITY = & class_loader('Security', 'classes');
159 159
 	$SECURITY->checkWhiteListIpAccess();
160 160
 	
161 161
 	/**
162 162
 	* Loading Url class
163 163
 	*/
164
-	$URL =& class_loader('Url', 'classes');
164
+	$URL = & class_loader('Url', 'classes');
165 165
 	
166
-	if(get_config('cache_enable', false)){
166
+	if (get_config('cache_enable', false)) {
167 167
 		/**
168 168
 		 * Load Cache interface file
169 169
 		 */
170 170
 		require_once CORE_CLASSES_CACHE_PATH . 'CacheInterface.php';
171 171
 		$cacheHandler = get_config('cache_handler');
172
-		if(! $cacheHandler){
172
+		if (!$cacheHandler) {
173 173
 			show_error('The cache feature is enabled in the configuration but the cache handler class is not set.');
174 174
 		}
175 175
 		$CACHE = null;
176 176
 		//first check if the cache handler is the system driver
177
-		if(file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')){
178
-			$CACHE =& class_loader($cacheHandler, 'classes/cache');
177
+		if (file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')) {
178
+			$CACHE = & class_loader($cacheHandler, 'classes/cache');
179 179
 		}
180
-		else{
180
+		else {
181 181
 			//it's not a system driver use user library
182
-			$CACHE =& class_loader($cacheHandler);
182
+			$CACHE = & class_loader($cacheHandler);
183 183
 		}
184 184
 		//check if the page already cached
185
-		if(! empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get'){
185
+		if (!empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get') {
186 186
 			$RESPONSE = & class_loader('Response', 'classes');
187 187
 			$RESPONSE->renderFinalPageFromCache($CACHE);
188 188
 		}
Please login to merge, or discard this patch.
core/classes/Config.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class Config{
27
+	class Config {
28 28
 		
29 29
 		/**
30 30
 		 * The list of loaded configuration
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 		 * The signleton of the logger
43 43
 		 * @return Object the Log instance
44 44
 		 */
45
-		private static function getLogger(){
46
-			if(static::$logger == null){
47
-				static::$logger[0] =& class_loader('Log', 'classes');
45
+		private static function getLogger() {
46
+			if (static::$logger == null) {
47
+				static::$logger[0] = & class_loader('Log', 'classes');
48 48
 				static::$logger[0]->setLogger('Library::Config');
49 49
 			}
50 50
 			return static::$logger[0];
@@ -53,35 +53,35 @@  discard block
 block discarded – undo
53 53
 		/**
54 54
 		 * Initialize the configuration by loading all the configuration from config file
55 55
 		 */
56
-		public static function init(){
56
+		public static function init() {
57 57
 			$logger = static::getLogger();
58 58
 			$logger->debug('Initialization of the configuration');
59 59
 			static::$config = & load_configurations();
60
-			if(! static::$config['base_url'] || ! is_url(static::$config['base_url'])){
61
-				if(ENVIRONMENT == 'production'){
60
+			if (!static::$config['base_url'] || !is_url(static::$config['base_url'])) {
61
+				if (ENVIRONMENT == 'production') {
62 62
 					$logger->warning('Application base URL is not set or invalid, please set application base URL to increase the application loading time');
63 63
 				}
64 64
 				$baseUrl = null;
65
-				if (isset($_SERVER['SERVER_ADDR'])){
65
+				if (isset($_SERVER['SERVER_ADDR'])) {
66 66
 					//check if the server is running under IPv6
67
-					if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE){
68
-						$baseUrl = '['.$_SERVER['SERVER_ADDR'].']';
67
+					if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE) {
68
+						$baseUrl = '[' . $_SERVER['SERVER_ADDR'] . ']';
69 69
 					}
70
-					else{
70
+					else {
71 71
 						$baseUrl = $_SERVER['SERVER_ADDR'];
72 72
 					}
73
-					$port = ((isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] != '80' && ! is_https() || $_SERVER['SERVER_PORT'] != '443' && is_https()) ) ? ':' . $_SERVER['SERVER_PORT'] : '');
74
-					$baseUrl = (is_https() ? 'https' : 'http').'://' . $baseUrl . $port
73
+					$port = ((isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] != '80' && !is_https() || $_SERVER['SERVER_PORT'] != '443' && is_https())) ? ':' . $_SERVER['SERVER_PORT'] : '');
74
+					$baseUrl = (is_https() ? 'https' : 'http') . '://' . $baseUrl . $port
75 75
 						. substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
76 76
 				}
77
-				else{
77
+				else {
78 78
 					$logger->warning('Can not determine the application base URL automatically, use http://localhost as default');
79 79
 					$baseUrl = 'http://localhost/';
80 80
 				}
81 81
 				self::set('base_url', $baseUrl);
82 82
 			}
83
-			static::$config['base_url'] = rtrim(static::$config['base_url'], '/') .'/';
84
-			if(ENVIRONMENT == 'production' && in_array(strtolower(static::$config['log_level']), array('debug', 'info','all'))){
83
+			static::$config['base_url'] = rtrim(static::$config['base_url'], '/') . '/';
84
+			if (ENVIRONMENT == 'production' && in_array(strtolower(static::$config['log_level']), array('debug', 'info', 'all'))) {
85 85
 				$logger->warning('You are in production environment, please set log level to WARNING, ERROR, FATAL to increase the application performance');
86 86
 			}
87 87
 			$logger->info('Configuration initialized successfully');
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 		 * @param  mixed $default the default value to use if can not find the config item in the list
95 95
 		 * @return mixed          the config value if exist or the default value
96 96
 		 */
97
-		public static function get($item, $default = null){
97
+		public static function get($item, $default = null) {
98 98
 			$logger = static::getLogger();
99
-			if(array_key_exists($item, static::$config)){
99
+			if (array_key_exists($item, static::$config)) {
100 100
 				return static::$config[$item];
101 101
 			}
102
-			$logger->warning('Cannot find config item ['.$item.'] using the default value ['.$default.']');
102
+			$logger->warning('Cannot find config item [' . $item . '] using the default value [' . $default . ']');
103 103
 			return $default;
104 104
 		}
105 105
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		 * @param string $item  the config item name to set
109 109
 		 * @param mixed $value the config item value
110 110
 		 */
111
-		public static function set($item, $value){
111
+		public static function set($item, $value) {
112 112
 			static::$config[$item] = $value;
113 113
 		}
114 114
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		 * Get all the configuration values
117 117
 		 * @return array the config values
118 118
 		 */
119
-		public static function getAll(){
119
+		public static function getAll() {
120 120
 			return static::$config;
121 121
 		}
122 122
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		 * Set the configuration values bu merged with the existing configuration
125 125
 		 * @param array $config the config values to add in the configuration list
126 126
 		 */
127
-		public static function setAll(array $config = array()){
127
+		public static function setAll(array $config = array()) {
128 128
 			static::$config = array_merge(static::$config, $config);
129 129
 		}
130 130
 
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 		 * @param  string $item the config item name to be deleted
134 134
 		 * @return boolean true if the item exists and is deleted successfully otherwise will return false.
135 135
 		 */
136
-		public static function delete($item){
136
+		public static function delete($item) {
137 137
 			$logger = static::getLogger();
138
-			if(array_key_exists($item, static::$config)){
139
-				$logger->info('Delete config item ['.$item.']');
138
+			if (array_key_exists($item, static::$config)) {
139
+				$logger->info('Delete config item [' . $item . ']');
140 140
 				unset(static::$config[$item]);
141 141
 				return true;
142 142
 			}
143
-			else{
144
-				$logger->warning('Config item ['.$item.'] to be deleted does not exists');
143
+			else {
144
+				$logger->warning('Config item [' . $item . '] to be deleted does not exists');
145 145
 				return false;
146 146
 			}
147 147
 		}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		 * Load the configuration file. This an alias with the Loader::config()
151 151
 		 * @param  string $config the config name to be loaded
152 152
 		 */
153
-		public static function load($config){
153
+		public static function load($config) {
154 154
 			Loader::config($config);
155 155
 		}
156 156
 	}
Please login to merge, or discard this patch.
core/classes/cache/FileCache.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class FileCache implements CacheInterface{
27
+	class FileCache implements CacheInterface {
28 28
 		
29 29
 		/**
30 30
 		 * Whether to enable compression of the cache data file.
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 		private static $logger;
40 40
 		
41 41
 		
42
-		public function __construct(){
43
-			if(! $this->isSupported()){
42
+		public function __construct() {
43
+			if (!$this->isSupported()) {
44 44
 				show_error('The cache for file system is not available. Check the cache directory if is exists or is writable.');
45 45
 			}
46 46
 			//if Zlib extension is not loaded set compressCacheData to false
47
-			if(! extension_loaded('zlib')){
47
+			if (!extension_loaded('zlib')) {
48 48
 				$logger = static::getLogger();
49 49
 				$logger->warning('The zlib extension is not loaded set cache compress data to FALSE');
50 50
 				$this->compressCacheData = false;
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 		 * Get the logger singleton instance
56 56
 		 * @return Log the logger instance
57 57
 		 */
58
-		private static function getLogger(){
59
-			if(static::$logger == null){
60
-				static::$logger[0] =& class_loader('Log', 'classes');
58
+		private static function getLogger() {
59
+			if (static::$logger == null) {
60
+				static::$logger[0] = & class_loader('Log', 'classes');
61 61
 				static::$logger[0]->setLogger('Library::FileCache');
62 62
 			}
63 63
 			return static::$logger[0];
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
 		 * @param  string $key the key to identify the cache data
69 69
 		 * @return mixed      the cache data if exists else return false
70 70
 		 */
71
-		public function get($key){
71
+		public function get($key) {
72 72
 			$logger = static::getLogger();
73
-			$logger->debug('Getting cache data for key ['. $key .']');
73
+			$logger->debug('Getting cache data for key [' . $key . ']');
74 74
 			$filePath = $this->getFilePath($key);
75
-			if(! file_exists($filePath)){
76
-				$logger->info('No cache file found for the key ['. $key .'], return false');
75
+			if (!file_exists($filePath)) {
76
+				$logger->info('No cache file found for the key [' . $key . '], return false');
77 77
 				return false;
78 78
 			}
79
-			$logger->info('The cache file [' .$filePath. '] for the key ['. $key .'] exists, check if the cache data is valid');
80
-			$handle = fopen($filePath,'r');
81
-			if( ! $handle){
82
-				$logger->error('Can not open the file cache [' .$filePath. '] for the key ['. $key .'], return false');
79
+			$logger->info('The cache file [' . $filePath . '] for the key [' . $key . '] exists, check if the cache data is valid');
80
+			$handle = fopen($filePath, 'r');
81
+			if (!$handle) {
82
+				$logger->error('Can not open the file cache [' . $filePath . '] for the key [' . $key . '], return false');
83 83
 				return false;
84 84
 			}
85 85
 			// Getting a shared lock 
@@ -87,20 +87,20 @@  discard block
 block discarded – undo
87 87
 		    $data = file_get_contents($filePath);
88 88
       		fclose($handle);
89 89
       		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
90
-      		if (! $data) {
91
-      			$logger->error('Can not unserialize the cache data for the key ['. $key .'], return false');
90
+      		if (!$data) {
91
+      			$logger->error('Can not unserialize the cache data for the key [' . $key . '], return false');
92 92
 		         // If unserializing somehow didn't work out, we'll delete the file
93 93
 		         unlink($filePath);
94 94
 		         return false;
95 95
 	      	}
96 96
 	      	if (time() > $data['expire']) {
97
-	      		$logger->info('The cache data for the key ['. $key .'] already expired delete the cache file [' .$filePath. ']');
97
+	      		$logger->info('The cache data for the key [' . $key . '] already expired delete the cache file [' . $filePath . ']');
98 98
 		        // Unlinking when the file was expired
99 99
 		        unlink($filePath);
100 100
 		        return false;
101 101
 		     }
102
-		     else{
103
-		     	$logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']');
102
+		     else {
103
+		     	$logger->info('The cache not yet expire, now return the cache data for key [' . $key . '], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']');
104 104
 		     	return $data['data'];
105 105
 		     }
106 106
 			return false;
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 		 * @param integer $ttl  the cache life time
115 115
 		 * @return boolean true if success otherwise will return false
116 116
 		 */
117
-		public function set($key, $data, $ttl = 0){
117
+		public function set($key, $data, $ttl = 0) {
118 118
 			$logger = static::getLogger();
119 119
 			$expire = time() + $ttl;
120
-			$logger->debug('Setting cache data for key ['. $key .'], time to live [' .$ttl. '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
120
+			$logger->debug('Setting cache data for key [' . $key . '], time to live [' . $ttl . '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
121 121
 			$filePath = $this->getFilePath($key);
122
-			$handle = fopen($filePath,'w');
123
-			if( ! $handle){
124
-				$logger->error('Can not open the file cache [' .$filePath. '] for the key ['. $key .'], return false');
122
+			$handle = fopen($filePath, 'w');
123
+			if (!$handle) {
124
+				$logger->error('Can not open the file cache [' . $filePath . '] for the key [' . $key . '], return false');
125 125
 				return false;
126 126
 			}
127 127
 			flock($handle, LOCK_EX); // exclusive lock, will get released when the file is closed
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 									)
135 135
 								);		   
136 136
 		    $result = fwrite($handle, $this->compressCacheData ? gzdeflate($cacheData, 9) : $cacheData);
137
-		    if(! $result){
138
-		    	$logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false');
137
+		    if (!$result) {
138
+		    	$logger->error('Can not write cache data into file [' . $filePath . '] for the key [' . $key . '], return false');
139 139
 		    	fclose($handle);
140 140
 		    	return false;
141 141
 		    }
142
-		    else{
143
-		    	$logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']');
142
+		    else {
143
+		    	$logger->info('Cache data saved into file [' . $filePath . '] for the key [' . $key . ']');
144 144
 		    	fclose($handle);
145 145
 				chmod($filePath, 0640);
146 146
 				return true;
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 		 * @return boolean      true if the cache is delete, false if can't delete 
155 155
 		 * the cache or the cache with the given key not exist
156 156
 		 */
157
-		public function delete($key){
157
+		public function delete($key) {
158 158
 			$logger = static::getLogger();
159
-			$logger->debug('Deleting of cache data for key [' .$key. ']');
159
+			$logger->debug('Deleting of cache data for key [' . $key . ']');
160 160
 			$filePath = $this->getFilePath($key);
161
-			$logger->info('The file path for the key [' .$key. '] is [' .$filePath. ']');
162
-			if(! file_exists($filePath)){
161
+			$logger->info('The file path for the key [' . $key . '] is [' . $filePath . ']');
162
+			if (!file_exists($filePath)) {
163 163
 				$logger->info('This cache file does not exists skipping');
164 164
 				return false;
165 165
 			}
166
-			else{
167
-				$logger->info('Found cache file [' .$filePath. '] remove it');
166
+			else {
167
+				$logger->info('Found cache file [' . $filePath . '] remove it');
168 168
 	      		@unlink($filePath);
169 169
 				return true;
170 170
 			}
@@ -178,26 +178,26 @@  discard block
 block discarded – undo
178 178
 		 * 'expire' => expiration time of the cache (Unix timestamp),
179 179
 		 * 'ttl' => the time to live of the cache in second
180 180
 		 */
181
-		public function getInfo($key){
181
+		public function getInfo($key) {
182 182
 			$logger = static::getLogger();
183
-			$logger->debug('Getting of cache info for key [' .$key. ']');
183
+			$logger->debug('Getting of cache info for key [' . $key . ']');
184 184
 			$filePath = $this->getFilePath($key);
185
-			$logger->info('The file path for the key [' .$key. '] is [' .$filePath. ']');
186
-			if(! file_exists($filePath)){
185
+			$logger->info('The file path for the key [' . $key . '] is [' . $filePath . ']');
186
+			if (!file_exists($filePath)) {
187 187
 				$logger->info('This cache file does not exists skipping');
188 188
 				return false;
189 189
 			}
190
-			else{
191
-				$logger->info('Found cache file [' .$filePath. '] check the validity');
190
+			else {
191
+				$logger->info('Found cache file [' . $filePath . '] check the validity');
192 192
 	      		$data = file_get_contents($filePath);
193 193
 				$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
194
-				if(! $data){
194
+				if (!$data) {
195 195
 					$logger->warning('Can not unserialize the cache data for file [' . $filePath . ']');
196 196
 					return false;
197 197
 				}
198
-				else{
198
+				else {
199 199
 					$logger->info('This cache data is OK check for expire');
200
-					if(isset($data['expire']) && $data['expire'] > time()){
200
+					if (isset($data['expire']) && $data['expire'] > time()) {
201 201
 						$logger->info('This cache not yet expired return cache informations');
202 202
 						$info = array(
203 203
 							'mtime' => $data['mtime'],
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 							);
207 207
 						return $info;
208 208
 					}
209
-					else{
209
+					else {
210 210
 						$logger->info('This cache already expired return false');
211 211
 						return false;
212 212
 					}
@@ -218,27 +218,27 @@  discard block
 block discarded – undo
218 218
 		/**
219 219
 		 * Used to delete expired cache data
220 220
 		 */
221
-		public function deleteExpiredCache(){
221
+		public function deleteExpiredCache() {
222 222
 			$logger = static::getLogger();
223 223
 			$logger->debug('Deleting of expired cache files');
224 224
 			$list = glob(CACHE_PATH . '*.cache');
225
-			if(! $list){
225
+			if (!$list) {
226 226
 				$logger->info('No cache files were found skipping');
227 227
 			}
228
-			else{
228
+			else {
229 229
 				$logger->info('Found [' . count($list) . '] cache files to remove if expired');
230 230
 				foreach ($list as $file) {
231 231
 					$logger->debug('Processing the cache file [' . $file . ']');
232 232
 					$data = file_get_contents($file);
233 233
 		      		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
234
-		      		if(! $data){
234
+		      		if (!$data) {
235 235
 		      			$logger->warning('Can not unserialize the cache data for file [' . $file . ']');
236 236
 		      		}
237
-		      		else if(time() > $data['expire']){
237
+		      		else if (time() > $data['expire']) {
238 238
 		      			$logger->info('The cache data for file [' . $file . '] already expired remove it');
239 239
 		      			@unlink($file);
240 240
 		      		}
241
-		      		else{
241
+		      		else {
242 242
 		      			$logger->info('The cache data for file [' . $file . '] not yet expired skip it');
243 243
 		      		}
244 244
 				}
@@ -248,14 +248,14 @@  discard block
 block discarded – undo
248 248
 		/**
249 249
 		 * Remove all file from cache folder
250 250
 		 */
251
-		public function clean(){
251
+		public function clean() {
252 252
 			$logger = static::getLogger();
253 253
 			$logger->debug('Deleting of all cache files');
254 254
 			$list = glob(CACHE_PATH . '*.cache');
255
-			if(! $list){
255
+			if (!$list) {
256 256
 				$logger->info('No cache files were found skipping');
257 257
 			}
258
-			else{
258
+			else {
259 259
 				$logger->info('Found [' . count($list) . '] cache files to remove');
260 260
 				foreach ($list as $file) {
261 261
 					$logger->debug('Processing the cache file [' . $file . ']');
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	    /**
268 268
 	     * @return boolean
269 269
 	     */
270
-	    public function isCompressCacheData(){
270
+	    public function isCompressCacheData() {
271 271
 	        return $this->compressCacheData;
272 272
 	    }
273 273
 
@@ -276,14 +276,14 @@  discard block
 block discarded – undo
276 276
 	     *
277 277
 	     * @return self
278 278
 	     */
279
-	    public function setCompressCacheData($status = true){
279
+	    public function setCompressCacheData($status = true) {
280 280
 			//if Zlib extension is not loaded set compressCacheData to false
281
-			if($status === true && ! extension_loaded('zlib')){
281
+			if ($status === true && !extension_loaded('zlib')) {
282 282
 				$logger = static::getLogger();
283 283
 				$logger->warning('The zlib extension is not loaded set cache compress data to FALSE');
284 284
 				$this->compressCacheData = false;
285 285
 			}
286
-			else{
286
+			else {
287 287
 				$this->compressCacheData = $status;
288 288
 			}
289 289
 			return $this;
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		 *
295 295
 		 * @return bool
296 296
 		 */
297
-		public function isSupported(){
297
+		public function isSupported() {
298 298
 			return CACHE_PATH && is_dir(CACHE_PATH) && is_writable(CACHE_PATH);
299 299
 		}
300 300
 		
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 		* @param $key the cache item key
305 305
 		* @return string the full cache file path for this key
306 306
 		*/
307
-		private function getFilePath($key){
307
+		private function getFilePath($key) {
308 308
 			return CACHE_PATH . md5($key) . '.cache';
309 309
 		}
310 310
 	}
311 311
\ No newline at end of file
Please login to merge, or discard this patch.
core/classes/cache/CacheInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 	
27
-	interface CacheInterface{
27
+	interface CacheInterface {
28 28
 
29 29
 		/**
30 30
 		 * This is used to get the cache data using the key
Please login to merge, or discard this patch.
core/classes/cache/ApcCache.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 	
27
-	class ApcCache implements CacheInterface{
27
+	class ApcCache implements CacheInterface {
28 28
 
29 29
 		/**
30 30
 		 * The logger instance
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 		private static $logger;
34 34
 		
35 35
 		
36
-		public function __construct(){
37
-			if(! $this->isSupported()){
36
+		public function __construct() {
37
+			if (!$this->isSupported()) {
38 38
 				show_error('The cache for APC[u] driver is not available. Check if APC[u] extension is loaded and enabled.');
39 39
 			}
40 40
 		}
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 		 * Get the logger singleton instance
44 44
 		 * @return Log the logger instance
45 45
 		 */
46
-		private static function getLogger(){
47
-			if(static::$logger == null){
48
-				static::$logger[0] =& class_loader('Log', 'classes');
46
+		private static function getLogger() {
47
+			if (static::$logger == null) {
48
+				static::$logger[0] = & class_loader('Log', 'classes');
49 49
 				static::$logger[0]->setLogger('Library::ApcCache');
50 50
 			}
51 51
 			return static::$logger[0];
@@ -56,22 +56,22 @@  discard block
 block discarded – undo
56 56
 		 * @param  string $key the key to identify the cache data
57 57
 		 * @return mixed      the cache data if exists else return false
58 58
 		 */
59
-		public function get($key){
59
+		public function get($key) {
60 60
 			$logger = static::getLogger();
61
-			$logger->debug('Getting cache data for key ['. $key .']');
61
+			$logger->debug('Getting cache data for key [' . $key . ']');
62 62
 			$success = false;
63 63
 			$data = apc_fetch($key, $success);
64
-			if($success === false){
65
-				$logger->info('No cache found for the key ['. $key .'], return false');
64
+			if ($success === false) {
65
+				$logger->info('No cache found for the key [' . $key . '], return false');
66 66
 				return false;
67 67
 			}
68
-			else{
68
+			else {
69 69
 				$cacheInfo = $this->_getCacheInfo($key);
70 70
 				$expire = time();
71
-				if($cacheInfo){
71
+				if ($cacheInfo) {
72 72
 					$expire = $cacheInfo['creation_time'] + $cacheInfo['ttl'];
73 73
 				}
74
-				$logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $expire) . ']');
74
+				$logger->info('The cache not yet expire, now return the cache data for key [' . $key . '], the cache will expire at [' . date('Y-m-d H:i:s', $expire) . ']');
75 75
 				return $data;
76 76
 			}
77 77
 		}
@@ -84,17 +84,17 @@  discard block
 block discarded – undo
84 84
 		 * @param integer $ttl  the cache life time
85 85
 		 * @return boolean true if success otherwise will return false
86 86
 		 */
87
-		public function set($key, $data, $ttl = 0){
87
+		public function set($key, $data, $ttl = 0) {
88 88
 			$logger = static::getLogger();
89 89
 			$expire = time() + $ttl;
90
-			$logger->debug('Setting cache data for key ['. $key .'], time to live [' .$ttl. '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
90
+			$logger->debug('Setting cache data for key [' . $key . '], time to live [' . $ttl . '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
91 91
 			$result = apc_store($key, $data, $ttl);
92
-			if($result === false){
93
-		    	$logger->error('Can not write cache data for the key ['. $key .'], return false');
92
+			if ($result === false) {
93
+		    	$logger->error('Can not write cache data for the key [' . $key . '], return false');
94 94
 		    	return false;
95 95
 		    }
96
-		    else{
97
-		    	$logger->info('Cache data saved for the key ['. $key .']');
96
+		    else {
97
+		    	$logger->info('Cache data saved for the key [' . $key . ']');
98 98
 		    	return true;
99 99
 		    }
100 100
 		}
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
 		 * @return boolean      true if the cache is deleted, false if can't delete 
107 107
 		 * the cache or the cache with the given key not exist
108 108
 		 */
109
-		public function delete($key){
109
+		public function delete($key) {
110 110
 			$logger = static::getLogger();
111
-			$logger->debug('Deleting of cache data for key [' .$key. ']');
111
+			$logger->debug('Deleting of cache data for key [' . $key . ']');
112 112
 			$cacheInfo = $this->_getCacheInfo($key);
113
-			if($cacheInfo === false){
113
+			if ($cacheInfo === false) {
114 114
 				$logger->info('This cache data does not exists skipping');
115 115
 				return false;
116 116
 			}
117
-			else{
118
-				$logger->info('Found cache data for the key [' .$key. '] remove it');
117
+			else {
118
+				$logger->info('Found cache data for the key [' . $key . '] remove it');
119 119
 	      		return apc_delete($key);
120 120
 			}
121 121
 			return false;
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
 		 * 'expire' => expiration time of the cache (Unix timestamp),
130 130
 		 * 'ttl' => the time to live of the cache in second
131 131
 		 */
132
-		public function getInfo($key){
132
+		public function getInfo($key) {
133 133
 			$logger = static::getLogger();
134
-			$logger->debug('Getting of cache info for key [' .$key. ']');
134
+			$logger->debug('Getting of cache info for key [' . $key . ']');
135 135
 			$cacheInfos = $this->_getCacheInfo($key);
136
-			if($cacheInfos){
136
+			if ($cacheInfos) {
137 137
 				$data = array(
138 138
 							'mtime' => $cacheInfos['creation_time'],
139 139
 							'expire' => $cacheInfos['creation_time'] + $cacheInfos['ttl'],
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 							);
142 142
 				return $data;
143 143
 			}
144
-			else{
144
+			else {
145 145
 				$logger->info('This cache does not exists skipping');
146 146
 				return false;
147 147
 			}
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		/**
152 152
 		 * Used to delete expired cache data
153 153
 		 */
154
-		public function deleteExpiredCache(){
154
+		public function deleteExpiredCache() {
155 155
 			//for APC[u] is done automatically
156 156
 			return true;
157 157
 		}
@@ -159,15 +159,15 @@  discard block
 block discarded – undo
159 159
 		/**
160 160
 		 * Remove all cache data
161 161
 		 */
162
-		public function clean(){
162
+		public function clean() {
163 163
 			$logger = static::getLogger();
164 164
 			$logger->debug('Deleting of all cache data');
165 165
 			$cacheInfos = apc_cache_info('user');
166
-			if(empty($cacheInfos['cache_list'])){
166
+			if (empty($cacheInfos['cache_list'])) {
167 167
 				$logger->info('No cache data were found skipping');
168 168
 				return false;
169 169
 			}
170
-			else{
170
+			else {
171 171
 				$logger->info('Found [' . count($cacheInfos) . '] cache data to remove');
172 172
 				return apc_clear_cache('user');
173 173
 			}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		 *
180 180
 		 * @return bool
181 181
 		 */
182
-		public function isSupported(){
182
+		public function isSupported() {
183 183
 			return (extension_loaded('apc') || extension_loaded('apcu')) && ini_get('apc.enabled');
184 184
 		}
185 185
 		
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
 		* @param string $key the cache key to get the cache information 
190 190
 		* @return array
191 191
 		*/
192
-		private function _getCacheInfo($key){
192
+		private function _getCacheInfo($key) {
193 193
 			$caches = apc_cache_info('user');
194
-			if(! empty($caches['cache_list'])){
194
+			if (!empty($caches['cache_list'])) {
195 195
 				$cacheLists = $caches['cache_list'];
196
-				foreach ($cacheLists as $c){
197
-					if(isset($c['info']) && $c['info'] === $key){
196
+				foreach ($cacheLists as $c) {
197
+					if (isset($c['info']) && $c['info'] === $key) {
198 198
 						return $c;
199 199
 					}
200 200
 				}
Please login to merge, or discard this patch.
core/classes/model/Model.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * @copyright Copyright (c) 2012, Jamie Rumbelow <http://jamierumbelow.net>
34 34
      */
35 35
 
36
-    abstract class Model{
36
+    abstract class Model {
37 37
 
38 38
         /* --------------------------------------------------------------
39 39
          * VARIABLES
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
          * Initialise the model, tie into the CodeIgniter superobject and
129 129
          * try our best to guess the table name.
130 130
          */
131
-        public function __construct(){
131
+        public function __construct() {
132 132
             $obj = & get_instance();
133
-    		if(!isset($obj->database)){
133
+    		if (!isset($obj->database)) {
134 134
     			show_error('You must load the database library before to use the model class');
135 135
             }
136 136
             /**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
             array_unshift($this->before_create, 'protect_attributes');
143 143
             array_unshift($this->before_update, 'protect_attributes');
144 144
             $this->_temporary_return_type = $this->return_type;
145
-            if($this->dbCacheTime > 0){
145
+            if ($this->dbCacheTime > 0) {
146 146
                 $this->_database->setCache($this->dbCacheTime);
147 147
             }
148 148
         }
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 
170 170
             if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
171 171
             {
172
-                $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
172
+                $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted);
173 173
             }
174 174
 
175 175
     		$this->_set_where($where);
176 176
 
177 177
             $this->trigger('before_get');
178
-			$type = $this->_temporary_return_type == 'array' ? 'array':false;
178
+			$type = $this->_temporary_return_type == 'array' ? 'array' : false;
179 179
             $row = $this->_database->from($this->_table)->get($type);
180 180
             $this->_temporary_return_type = $this->return_type;
181 181
             $row = $this->trigger('after_get', $row);
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
             $this->trigger('before_get');
212 212
             if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
213 213
             {
214
-                $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
214
+                $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted);
215 215
             }
216
-			$type = $this->_temporary_return_type == 'array' ? 'array':false;
216
+			$type = $this->_temporary_return_type == 'array' ? 'array' : false;
217 217
             $result = $this->_database->from($this->_table)->getAll($type);
218 218
             $this->_temporary_return_type = $this->return_type;
219 219
 
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
         {
320 320
             $args = func_get_args();
321 321
             $data = array();
322
-            if(count($args) == 2){
323
-                if(is_array($args[1])){
322
+            if (count($args) == 2) {
323
+                if (is_array($args[1])) {
324 324
                     $data = array_pop($args);
325 325
                 }
326 326
             }
327
-            else if(count($args) == 3){
328
-                if(is_array($args[2])){
327
+            else if (count($args) == 3) {
328
+                if (is_array($args[2])) {
329 329
                     $data = array_pop($args);
330 330
                 }
331 331
             }
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
             $this->_database->where($this->primary_key, $id);
364 364
             if ($this->soft_delete)
365 365
             {
366
-                $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE ));
366
+                $result = $this->_database->from($this->_table)->update(array($this->soft_delete_key => TRUE));
367 367
             }
368 368
             else
369 369
             {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
             $this->_set_where($where);
385 385
             if ($this->soft_delete)
386 386
             {
387
-                $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE ));
387
+                $result = $this->_database->from($this->_table)->update(array($this->soft_delete_key => TRUE));
388 388
             }
389 389
             else
390 390
             {
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
             $this->_database->in($this->primary_key, $primary_values);
404 404
             if ($this->soft_delete)
405 405
             {
406
-                $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE ));
406
+                $result = $this->_database->from($this->_table)->update(array($this->soft_delete_key => TRUE));
407 407
             }
408 408
             else
409 409
             {
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
                 if (is_string($value))
450 450
                 {
451 451
                     $relationship = $value;
452
-                    $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' );
452
+                    $options = array('primary_key' => $value . '_id', 'model' => $value . '_model');
453 453
                 }
454 454
                 else
455 455
                 {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
                 if (is_string($value))
477 477
                 {
478 478
                     $relationship = $value;
479
-                    $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' );
479
+                    $options = array('primary_key' => $this->_table . '_id', 'model' => $value . '_model');
480 480
                 }
481 481
                 else
482 482
                 {
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
         public function dropdown()
511 511
         {
512 512
             $args = func_get_args();
513
-            if(count($args) == 2)
513
+            if (count($args) == 2)
514 514
             {
515 515
                 list($key, $value) = $args;
516 516
             }
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
                 $key = $this->primary_key;
520 520
                 $value = $args[0];
521 521
             }
522
-            $this->trigger('before_dropdown', array( $key, $value ));
522
+            $this->trigger('before_dropdown', array($key, $value));
523 523
             if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
524 524
             {
525 525
                 $this->_database->where($this->soft_delete_key, FALSE);
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
         {
544 544
             if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
545 545
             {
546
-                $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
546
+                $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted);
547 547
             }
548 548
             $where = func_get_args();
549 549
             $this->_set_where($where);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
         {
559 559
             if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
560 560
             {
561
-                $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
561
+                $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted);
562 562
             }
563 563
             $this->_database->from($this->_table)->getAll();
564 564
             return $this->_database->numRows();
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
 		/**
568 568
 		* Enabled cache temporary
569 569
 		*/
570
-		public function cached($ttl = 0){
571
-		  if($ttl > 0){
570
+		public function cached($ttl = 0) {
571
+		  if ($ttl > 0) {
572 572
 			$this->_database = $this->_database->cached($ttl);
573 573
 		  }
574 574
 		  return $this;
@@ -722,13 +722,13 @@  discard block
 block discarded – undo
722 722
             {
723 723
                 if (is_object($row))
724 724
                 {
725
-					if(isset($row->$attr)){
725
+					if (isset($row->$attr)) {
726 726
 						unset($row->$attr);
727 727
 					}
728 728
                 }
729 729
                 else
730 730
                 {
731
-					if(isset($row[$attr])){
731
+					if (isset($row[$attr])) {
732 732
 						unset($row[$attr]);
733 733
 					}
734 734
                 }
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
          * Return the database instance
741 741
          * @return Database the database instance
742 742
          */
743
-        public function getDatabaseInstance(){
743
+        public function getDatabaseInstance() {
744 744
             return $this->_database;
745 745
         }
746 746
 
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
          */
754 754
         public function order_by($criteria, $order = 'ASC')
755 755
         {
756
-            if ( is_array($criteria) )
756
+            if (is_array($criteria))
757 757
             {
758 758
                 foreach ($criteria as $key => $value)
759 759
                 {
@@ -809,18 +809,18 @@  discard block
 block discarded – undo
809 809
          */
810 810
         protected function validate(array $data)
811 811
         {
812
-            if($this->skip_validation)
812
+            if ($this->skip_validation)
813 813
             {
814 814
                 return $data;
815 815
             }
816
-            if(!empty($this->validate))
816
+            if (!empty($this->validate))
817 817
             {
818
-                foreach($data as $key => $val)
818
+                foreach ($data as $key => $val)
819 819
                 {
820 820
                     $_POST[$key] = $val;
821 821
                 }
822 822
                 Loader::library('FormValidation');
823
-                if(is_array($this->validate))
823
+                if (is_array($this->validate))
824 824
                 {
825 825
                     $this->formvalidation->setRules($this->validate);
826 826
 
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
             {
875 875
                 $this->_database->where($params[0]);
876 876
             }
877
-        	else if(count($params) == 2)
877
+        	else if (count($params) == 2)
878 878
     		{
879 879
                 if (is_array($params[1]))
880 880
                 {
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
                     $this->_database->where($params[0], $params[1]);
886 886
                 }
887 887
     		}
888
-    		else if(count($params) == 3)
888
+    		else if (count($params) == 3)
889 889
     		{
890 890
     			$this->_database->where($params[0], $params[1], $params[2]);
891 891
     		}
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
         /**
906 906
             Shortcut to controller
907 907
         */
908
-        public function __get($key){
908
+        public function __get($key) {
909 909
             return get_instance()->{$key};
910 910
         }
911 911
 
Please login to merge, or discard this patch.
core/classes/model/DBSessionHandlerModel.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@
 block discarded – undo
45 45
 		 */
46 46
 		protected $sessionTableColumns = array();
47 47
 
48
-		public function __construct(){
48
+		public function __construct() {
49 49
 			parent::__construct();
50 50
 		}
51 51
 
52
-		public function getSessionTableColumns(){
52
+		public function getSessionTableColumns() {
53 53
 			return $this->sessionTableColumns;
54 54
 		}
55 55
 
Please login to merge, or discard this patch.