Conditions | 8 |
Paths | 128 |
Total Lines | 58 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
32 | protected function construct () { |
||
33 | $this->config = $this->load_config(); |
||
34 | _include_once(DIR.'/config/main.php', false); |
||
35 | defined('DEBUG') || define('DEBUG', false); |
||
36 | defined('DOMAIN') || define('DOMAIN', $this->config['domain']); |
||
37 | date_default_timezone_set($this->config['timezone']); |
||
38 | if (!is_dir(PUBLIC_STORAGE)) { |
||
39 | /** @noinspection MkdirRaceConditionInspection */ |
||
40 | @mkdir(PUBLIC_STORAGE, 0775, true); |
||
41 | file_put_contents( |
||
42 | PUBLIC_STORAGE.'/.htaccess', |
||
43 | 'Allow From All |
||
44 | <ifModule mod_headers.c> |
||
45 | Header always append X-Frame-Options DENY |
||
46 | Header set Content-Type application/octet-stream |
||
47 | </ifModule> |
||
48 | ' |
||
49 | ); |
||
50 | } |
||
51 | if (!is_dir(CACHE)) { |
||
52 | /** @noinspection MkdirRaceConditionInspection */ |
||
53 | @mkdir(CACHE, 0770); |
||
54 | } |
||
55 | if (!is_dir(PUBLIC_CACHE)) { |
||
56 | /** @noinspection MkdirRaceConditionInspection */ |
||
57 | @mkdir(PUBLIC_CACHE, 0770); |
||
58 | file_put_contents( |
||
59 | PUBLIC_CACHE.'/.htaccess', |
||
60 | '<FilesMatch "\.(css|js|html)$"> |
||
61 | Allow From All |
||
62 | </FilesMatch> |
||
63 | <ifModule mod_expires.c> |
||
64 | ExpiresActive On |
||
65 | ExpiresDefault "access plus 1 month" |
||
66 | </ifModule> |
||
67 | <ifModule mod_headers.c> |
||
68 | Header set Cache-Control "max-age=2592000, public" |
||
69 | </ifModule> |
||
70 | AddEncoding gzip .js |
||
71 | AddEncoding gzip .css |
||
72 | AddEncoding gzip .html |
||
73 | ' |
||
74 | ); |
||
75 | } |
||
76 | if (!is_dir(LOGS)) { |
||
77 | /** @noinspection MkdirRaceConditionInspection */ |
||
78 | @mkdir(LOGS, 0770); |
||
79 | } |
||
80 | if (!is_dir(TEMP)) { |
||
81 | /** @noinspection MkdirRaceConditionInspection */ |
||
82 | @mkdir(TEMP, 0775); |
||
83 | file_put_contents( |
||
84 | TEMP.'/.htaccess', |
||
85 | "Allow From All\n" |
||
86 | ); |
||
87 | } |
||
88 | $this->constructed = true; |
||
89 | } |
||
90 | /** |
||
153 |