Completed
Push — master ( 85914a...2ce878 )
by Harald
06:39 queued 03:01
created

actionRecorderAdmin::actionRecorderAdmin()   D

Complexity

Conditions 10
Paths 11

Size

Total Lines 35
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 22
nc 11
nop 3
dl 0
loc 35
rs 4.8196
c 0
b 0
f 0

How to fix   Complexity   

Long Method

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:

1
<?php
2
/*
3
  $Id$
4
5
  osCommerce, Open Source E-Commerce Solutions
6
  http://www.oscommerce.com
7
8
  Copyright (c) 2010 osCommerce
9
10
  Released under the GNU General Public License
11
*/
12
13
  use OSC\OM\HTML;
14
  use OSC\OM\OSCOM;
15
  use OSC\OM\Registry;
16
17
  require(OSCOM::getConfig('dir_root', 'Shop') . 'includes/classes/action_recorder.php');
18
19
  class actionRecorderAdmin extends actionRecorder {
20
    function __construct($module, $user_id = null, $user_name = null) {
21
      global $PHP_SELF;
22
23
      $this->lang = Registry::get('Language');
24
25
      $module = HTML::sanitize(str_replace(' ', '', $module));
26
27
      if (defined('MODULE_ACTION_RECORDER_INSTALLED') && tep_not_null(MODULE_ACTION_RECORDER_INSTALLED)) {
28
        if (tep_not_null($module) && in_array($module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), explode(';', MODULE_ACTION_RECORDER_INSTALLED))) {
29
          if (!class_exists($module)) {
30
            if (is_file(OSCOM::getConfig('dir_root', 'Shop') . 'includes/modules/action_recorder/' . $module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)))) {
31
              $this->lang->loadDefinitions('Shop/modules/action_recorder/' . $module);
32
              include(OSCOM::getConfig('dir_root', 'Shop') . 'includes/modules/action_recorder/' . $module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)));
33
            } else {
34
              return false;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
35
            }
36
          }
37
        } else {
38
          return false;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
39
        }
40
      } else {
41
        return false;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
42
      }
43
44
      $this->_module = $module;
45
46
      if (!empty($user_id) && is_numeric($user_id)) {
47
        $this->_user_id = $user_id;
48
      }
49
50
      if (!empty($user_name)) {
51
        $this->_user_name = $user_name;
52
      }
53
54
      $GLOBALS[$this->_module] = new $module();
55
      $GLOBALS[$this->_module]->setIdentifier();
56
    }
57
  }
58
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
59