| Conditions | 8 |
| Paths | 47 |
| Total Lines | 54 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 26 | public function __construct() { |
||
| 27 | |||
| 28 | try { |
||
| 29 | |||
| 30 | $this->CI = get_instance(); |
||
| 31 | |||
| 32 | if (function_exists('date_default_timezone_set')) { |
||
| 33 | date_default_timezone_set(config_item('default_time_zone')); |
||
| 34 | } |
||
| 35 | |||
| 36 | // Sessions engine should run on cookies to minimize opportunities |
||
| 37 | // of session fixation attack |
||
| 38 | ini_set('session.use_only_cookies', 1); |
||
| 39 | |||
| 40 | $this->CI->load->library('native_session', '', 'session'); |
||
| 41 | |||
| 42 | $this->CI->load->library('cache'); |
||
| 43 | |||
| 44 | if (!$this->checkIsInstalled()) { // if not installed then not all bootstrap needed |
||
| 45 | return; |
||
| 46 | } |
||
| 47 | |||
| 48 | $this->initDatabase(); |
||
| 49 | |||
| 50 | $this->initPropel(); |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @todo |
||
| 54 | * 1. Delete this line |
||
| 55 | * 2. Kill all eval && hooks before delete this line |
||
| 56 | */ |
||
| 57 | $this->CI->load->library('cms_hooks'); |
||
| 58 | |||
| 59 | $this->CI->load->library('lib_category'); // needs database |
||
| 60 | |||
| 61 | // Redirect to url with out ending slash |
||
| 62 | $uri = $this->_detect_uri(); |
||
| 63 | |||
| 64 | $first_segment = $this->CI->uri->segment(1); |
||
| 65 | if (substr($uri, -1, 1) === '/' && $first_segment !== 'admin' && $uri !== '/') { |
||
| 66 | $get_params = ''; |
||
| 67 | if ($this->CI->input->get()) { |
||
| 68 | $get_params = '?' . http_build_query($this->CI->input->get()); |
||
| 69 | } |
||
| 70 | redirect(substr($uri, 0, -1) . $get_params, 'location', 301); |
||
| 71 | } |
||
| 72 | |||
| 73 | $this->initShop(); |
||
| 74 | |||
| 75 | } catch (Exception $ex) { |
||
| 76 | log_message('error', $ex->getMessage()); |
||
| 77 | show_error('Init error', 500); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 206 | } |