| Conditions | 9 |
| Paths | 94 |
| Total Lines | 66 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | 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 | /* |
||
| 29 | * include composer autoloader |
||
| 30 | */ |
||
| 31 | include_once APPPATH . 'third_party/autoload.php'; |
||
| 32 | |||
| 33 | /* |
||
| 34 | * Define DS for Premmerce compatibility |
||
| 35 | * TODO: Remove DS usage from all project |
||
| 36 | * |
||
| 37 | */ |
||
| 38 | defined('DS') or define('DS', '/'); |
||
| 39 | |||
| 40 | try { |
||
| 41 | |||
| 42 | $this->CI = get_instance(); |
||
| 43 | |||
| 44 | if (function_exists('date_default_timezone_set')) { |
||
| 45 | date_default_timezone_set(config_item('default_time_zone')); |
||
| 46 | } |
||
| 47 | |||
| 48 | // Sessions engine should run on cookies to minimize opportunities |
||
| 49 | // of session fixation attack |
||
| 50 | ini_set('session.use_only_cookies', 1); |
||
| 51 | |||
| 52 | $this->CI->load->library('native_session', '', 'session'); |
||
| 53 | |||
| 54 | $this->CI->load->library('cache'); |
||
| 55 | |||
| 56 | if (!$this->checkIsInstalled()) { // if not installed then not all bootstrap needed |
||
| 57 | return; |
||
| 58 | } |
||
| 59 | |||
| 60 | $this->initDatabase(); |
||
| 61 | |||
| 62 | $this->initPropel(); |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @todo |
||
| 66 | * 1. Delete this line |
||
| 67 | * 2. Kill all eval && hooks before delete this line |
||
| 68 | */ |
||
| 69 | $this->CI->load->library('cms_hooks'); |
||
| 70 | |||
| 71 | $this->CI->load->library('lib_category'); // needs database |
||
| 72 | |||
| 73 | // Redirect to url with out ending slash |
||
| 74 | $uri = $this->_detect_uri(); |
||
| 75 | |||
| 76 | $first_segment = $this->CI->uri->segment(1); |
||
| 77 | if (substr($uri, -1, 1) === '/' && $first_segment !== 'admin' && $uri !== '/') { |
||
| 78 | $get_params = ''; |
||
| 79 | if ($this->CI->input->get()) { |
||
| 80 | $get_params = '?' . http_build_query($this->CI->input->get()); |
||
| 81 | } |
||
| 82 | redirect(substr($uri, 0, -1) . $get_params, 'location', 301); |
||
| 83 | } |
||
| 84 | |||
| 85 | $this->initShop(); |
||
| 86 | |||
| 87 | } catch (Exception $ex) { |
||
| 88 | log_message('error', $ex->getMessage()); |
||
| 89 | show_error('Init error', 500); |
||
| 90 | } |
||
| 91 | } |
||
| 92 | |||
| 217 | } |