| Conditions | 2 |
| Paths | 2 |
| Total Lines | 69 |
| Code Lines | 49 |
| 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 |
||
| 76 | public function install(): bool |
||
| 77 | { |
||
| 78 | // create the table |
||
| 79 | try { |
||
| 80 | $this->schemaTool->create([ |
||
| 81 | IntrusionEntity::class |
||
| 82 | ]); |
||
| 83 | } catch (Exception $exception) { |
||
| 84 | return false; |
||
| 85 | } |
||
| 86 | |||
| 87 | // Set up an initial value for a module variable. |
||
| 88 | $this->setVar('itemsperpage', 10); |
||
| 89 | |||
| 90 | // We use config vars for the rest of the configuration as config vars |
||
| 91 | $this->setSystemVar('updatecheck', 1); |
||
| 92 | $this->setSystemVar('updatefrequency', 7); |
||
| 93 | $this->setSystemVar('updatelastchecked', 0); |
||
| 94 | $this->setSystemVar('updateversion', ZikulaKernel::VERSION); |
||
| 95 | $this->setSystemVar('seclevel', 'Medium'); |
||
| 96 | $this->setSystemVar('secmeddays', 7); |
||
| 97 | $this->setSystemVar('secinactivemins', 20); |
||
| 98 | $this->setSystemVar('sessionstoretofile', Constant::SESSION_STORAGE_FILE); |
||
| 99 | $this->setSystemVar('sessionsavepath'); |
||
| 100 | $this->setSystemVar('gc_probability', 100); |
||
| 101 | $this->setSystemVar('sessionregenerate', 1); |
||
| 102 | $this->setSystemVar('sessionregeneratefreq', 10); |
||
| 103 | $this->setSystemVar('sessionname', '_zsid'); |
||
| 104 | |||
| 105 | $this->setSystemVar('filtergetvars', 1); |
||
| 106 | $this->setSystemVar('filterpostvars', 1); |
||
| 107 | $this->setSystemVar('filtercookievars', 1); |
||
| 108 | |||
| 109 | // HTML Purifier cache dir |
||
| 110 | $this->cacheClearer->clear('purifier'); |
||
| 111 | |||
| 112 | // HTML Purifier default settings |
||
| 113 | $purifierDefaultConfig = $this->purifierHelper->getPurifierConfig(['forcedefault' => true]); |
||
| 114 | $this->setVar('htmlpurifierConfig', serialize($purifierDefaultConfig)); |
||
| 115 | |||
| 116 | // create vars for phpids usage |
||
| 117 | $this->setSystemVar('useids', 0); |
||
| 118 | $this->setSystemVar('idsmail', 0); |
||
| 119 | $this->setSystemVar('idsrulepath', 'system/SecurityCenterModule/Resources/config/phpids_zikula_default.xml'); |
||
| 120 | $this->setSystemVar('idssoftblock', 1); // do not block requests, but warn for debugging |
||
| 121 | $this->setSystemVar('idsfilter', 'xml'); // filter type |
||
| 122 | $this->setSystemVar('idsimpactthresholdone', 1); // db logging |
||
| 123 | $this->setSystemVar('idsimpactthresholdtwo', 10); // mail admin |
||
| 124 | $this->setSystemVar('idsimpactthresholdthree', 25); // block request |
||
| 125 | $this->setSystemVar('idsimpactthresholdfour', 75); // kick user, destroy session |
||
| 126 | $this->setSystemVar('idsimpactmode', 1); // per request per default |
||
| 127 | $this->setSystemVar('idshtmlfields', ['POST.__wysiwyg']); |
||
| 128 | $this->setSystemVar('idsjsonfields', ['POST.__jsondata']); |
||
| 129 | $this->setSystemVar('idsexceptions', [ |
||
| 130 | 'GET.__utmz', |
||
| 131 | 'GET.__utmc', |
||
| 132 | 'REQUEST.linksorder', 'POST.linksorder', |
||
| 133 | 'REQUEST.fullcontent', 'POST.fullcontent', |
||
| 134 | 'REQUEST.summarycontent', 'POST.summarycontent', |
||
| 135 | 'REQUEST.filter.page', 'POST.filter.page', |
||
| 136 | 'REQUEST.filter.value', 'POST.filter.value' |
||
| 137 | ]); |
||
| 138 | $this->setSystemVar('outputfilter', 1); |
||
| 139 | |||
| 140 | $this->setSystemVar('htmlentities', 1); |
||
| 141 | $this->setSystemVar('AllowableHTML', $this->htmlTagsHelper->getDefaultValues()); |
||
| 142 | |||
| 143 | // Initialisation successful |
||
| 144 | return true; |
||
| 145 | } |
||
| 206 |