Conditions | 8 |
Paths | 24 |
Total Lines | 80 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
17 | public function __construct($title) |
||
18 | { |
||
19 | \Sentry\init(['dsn' => 'https://[email protected]/4283882' ]); |
||
20 | $this->settings = \Flipside\Settings::getInstance(); |
||
|
|||
21 | $this->loader = new \Twig_Loader_Filesystem(dirname(__FILE__).'/../templates'); |
||
22 | |||
23 | $twigSettings = array(); |
||
24 | if(\file_exists('/var/php_cache/twig')) |
||
25 | { |
||
26 | $twigCache = $this->settings->getGlobalSetting('twig_cache', '/var/php_cache/twig'); |
||
27 | $twigSettings['cache'] = $twigCache; |
||
28 | //$twigSettings = array('cache' => $twigCache, 'debug' => true); |
||
29 | } |
||
30 | //$twigSettings['debug'] = true; |
||
31 | |||
32 | $this->wwwUrl = $this->settings->getGlobalSetting('www_url', 'https://www.burningflipside.com'); |
||
33 | $this->wikiUrl = $this->settings->getGlobalSetting('wiki_url', 'https://wiki.burningflipside.com'); |
||
34 | $this->secureUrl = $this->settings->getGlobalSetting('secure_url', 'https://secure.burningflipside.com'); |
||
35 | $this->profilesUrl = $this->settings->getGlobalSetting('profiles_url', 'https://profiles.burningflipside.com'); |
||
36 | $this->registerUrl = $this->settings->getGlobalSetting('register_url', $this->profilesUrl.'/register.php'); |
||
37 | $this->resetUrl = $this->settings->getGlobalSetting('reset_url', $this->profilesUrl.'/reset.php'); |
||
38 | $this->loginUrl = $this->settings->getGlobalSetting('login_url', $this->profilesUrl.'/login.php'); |
||
39 | $this->logoutUrl = $this->settings->getGlobalSetting('logout_url', $this->profilesUrl.'/logout.php'); |
||
40 | |||
41 | $this->twig = new \Twig_Environment($this->loader, $twigSettings); |
||
42 | //$this->twig->addExtension(new \Twig\Extension\DebugExtension()); |
||
43 | $this->content = array('pageTitle' => $title); |
||
44 | $this->user = \Flipside\FlipSession::getUser(); |
||
45 | $this->content['user'] = $this->user; |
||
46 | $this->content['header'] = array(); |
||
47 | $this->content['header']['sites'] = array(); |
||
48 | $this->content['header']['sites']['Profiles'] = $this->profilesUrl; |
||
49 | $this->content['header']['sites']['WWW'] = $this->wwwUrl; |
||
50 | $this->content['header']['sites']['Pyropedia'] = $this->wikiUrl; |
||
51 | $this->content['header']['sites']['Secure'] = $this->secureUrl; |
||
52 | |||
53 | $this->aboutUrl = $this->settings->getGlobalSetting('about_url', $this->wwwUrl.'/about'); |
||
54 | $this->content['header']['right']['About'] = array( |
||
55 | 'url' => $this->aboutUrl, |
||
56 | 'menu' => $this->settings->getGlobalSetting('about_menu', array( |
||
57 | 'Burning Flipside' => $this->wwwUrl.'/about/event', |
||
58 | 'AAR, LLC' => $this->wwwUrl.'/organization/aar', |
||
59 | 'Privacy Policy' => $this->wwwUrl.'/about/privacy' |
||
60 | ))); |
||
61 | |||
62 | $this->content['urls']['wwwUrl'] = $this->wwwUrl; |
||
63 | $this->content['urls']['wikiUrl'] = $this->wikiUrl; |
||
64 | $this->content['urls']['profilesUrl'] = $this->profilesUrl; |
||
65 | $this->content['urls']['secureUrl'] = $this->secureUrl; |
||
66 | |||
67 | $this->content['urls']['registerUrl'] = $this->registerUrl; |
||
68 | $this->content['urls']['resetUrl'] = $this->resetUrl; |
||
69 | $this->content['urls']['loginUrl'] = $this->loginUrl; |
||
70 | $this->content['urls']['logoutUrl'] = $this->logoutUrl; |
||
71 | |||
72 | if($this->user === false || $this->user === null) |
||
73 | { |
||
74 | if(isset($_SERVER['REQUEST_URI']) && strstr($_SERVER['REQUEST_URI'], 'logout.php') === false) |
||
75 | { |
||
76 | $this->addLink('Login', $this->loginUrl); |
||
77 | } |
||
78 | } |
||
79 | else |
||
80 | { |
||
81 | $this->addLink('Logout', $this->settings->getGlobalSetting('logout_url', $this->profilesUrl.'/logout.php')); |
||
82 | $this->addLinks(); |
||
83 | } |
||
84 | |||
85 | $this->minified = 'min'; |
||
86 | $this->cdn = 'cdn'; |
||
87 | if($this->settings->getGlobalSetting('use_minified', true) == false) |
||
88 | { |
||
89 | $this->minified = 'no'; |
||
90 | } |
||
91 | if($this->settings->getGlobalSetting('use_cdn', true) == false) |
||
92 | { |
||
93 | $this->cdn = 'no'; |
||
94 | $this->content['useCDN'] = false; |
||
95 | } |
||
96 | } |
||
97 | |||
261 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: