| Conditions | 3 |
| Paths | 4 |
| Total Lines | 74 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 2 |
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 |
||
| 65 | function add_header() |
||
| 66 | { |
||
| 67 | $sites = ''; |
||
| 68 | $log = ''; |
||
| 69 | foreach($this->sites as $link => $site_name) |
||
| 70 | { |
||
| 71 | $sites .= '<li><a href="'.$site_name.'">'.$link.'</a></li>'; |
||
| 72 | } |
||
| 73 | if(!FlipSession::isLoggedIn()) |
||
| 74 | { |
||
| 75 | $log = '<a href="../login.php?return='.$this->current_url().'"><span class="glyphicon glyphicon-log-in"></span></a>'; |
||
| 76 | } |
||
| 77 | else |
||
| 78 | { |
||
| 79 | $log = '<a href="../logout.php"><span class="glyphicon glyphicon-log-out"></span></a>'; |
||
| 80 | } |
||
| 81 | $this->body = '<div id="wrapper"> |
||
| 82 | <nav class="navbar navbar-default navbar-static-top" role=navigation" style="margin-bottom: 0"> |
||
| 83 | <div class="navbar-header"> |
||
| 84 | <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse"> |
||
| 85 | <span class="sr-only">Toggle Navigation</span> |
||
| 86 | <span class="icon-bar"></span> |
||
| 87 | <span class="icon-bar"></span> |
||
| 88 | <span class="icon-bar"></span> |
||
| 89 | </button> |
||
| 90 | <a class="navbar-brand" href="index.php">Leads</a> |
||
| 91 | </div> |
||
| 92 | <ul class="nav navbar-top-links navbar-right links"> |
||
| 93 | <a href="../"> |
||
| 94 | <span class="glyphicon glyphicon-home"></span> |
||
| 95 | </a> |
||
| 96 | |
||
| 97 | '.$log.' |
||
| 98 | <li class="dropdown"> |
||
| 99 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"> |
||
| 100 | <span class="glyphicon glyphicon-link"></span> |
||
| 101 | <b class="caret"></b> |
||
| 102 | </a> |
||
| 103 | <ul class="dropdown-menu dropdown-sites"> |
||
| 104 | '.$sites.' |
||
| 105 | </ul> |
||
| 106 | </li> |
||
| 107 | </ul> |
||
| 108 | <div class="navbar-default sidebar" role="navigation"> |
||
| 109 | <div class="sidebar-nav navbar-collapse" style="height: 1px;"> |
||
| 110 | <ul class="nav" id="side-menu"> |
||
| 111 | <li> |
||
| 112 | <a href="index.php"><span class="glyphicon glyphicon-dashboard"></span> Dashboard</a> |
||
| 113 | </li> |
||
| 114 | <li> |
||
| 115 | <a href="#"><span class="glyphicon glyphicon-th-list"></span> Directory</a> |
||
| 116 | <ul class="nav nav-second-level collapse"> |
||
| 117 | <li><a href="directory.php">All</a></li> |
||
| 118 | <li><a href="directory.php?filter=aar">AAR</a></li> |
||
| 119 | <li><a href="directory.php?filter=af">AFs</a></li> |
||
| 120 | <li><a href="directory.php?filter=cc">CC</a></li> |
||
| 121 | <li><a href="directory.php?filter=360">360/24/7 Department</a></li> |
||
| 122 | <li><a href="directory.php?filter=Art">Art</a></li> |
||
| 123 | <li><a href="directory.php?filter=CityPlanning">City Planning</a></li> |
||
| 124 | <li><a href="directory.php?filter=Comm">Communications</a></li> |
||
| 125 | <li><a href="directory.php?filter=Safety">Safety</a></li> |
||
| 126 | <li><a href="directory.php?filter=site-ops">Site-Ops</a></li> |
||
| 127 | <li><a href="directory.php?filter=siteprep">Site Prep</a></li> |
||
| 128 | <li><a href="directory.php?filter=sign-off">Site Sign-Off</a></li> |
||
| 129 | <li><a href="directory.php?filter=vc">Volunteer Coordinator</a></li> |
||
| 130 | </ul> |
||
| 131 | </li> |
||
| 132 | </ul> |
||
| 133 | </div> |
||
| 134 | </div> |
||
| 135 | </nav> |
||
| 136 | <div id="page-wrapper" style="min-height: 538px;">'.$this->body.'</div></div>'; |
||
| 137 | $this->add_login_form(); |
||
| 138 | } |
||
| 139 | |||
| 189 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.