Conditions | 3 |
Paths | 3 |
Total Lines | 52 |
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 |
||
74 | protected function analyseUserGroups(&$reports) |
||
75 | { |
||
76 | /** @var \AOE\AoeIpauth\Domain\Service\FeEntityService $service */ |
||
77 | $service = $this->objectManager->get('AOE\\AoeIpauth\\Domain\\Service\\FeEntityService'); |
||
78 | |||
79 | $userGroups = $service->findAllGroupsWithIpAuthentication(); |
||
80 | |||
81 | if (empty($userGroups)) { |
||
82 | // Message that no user group has IP authentication |
||
83 | $reports[] = $this->objectManager->get( |
||
84 | 'TYPO3\\CMS\\Reports\\Status', |
||
85 | 'IP Usergroup Authentication', |
||
86 | 'No user groups with IP authentication found', |
||
87 | 'No user groups were found anywhere that are active and have an automatic IP authentication enabled.' . |
||
88 | 'Your current IP is: <strong>' . $this->myIp . '</strong>', |
||
89 | \TYPO3\CMS\Reports\Status::INFO |
||
90 | ); |
||
91 | } else { |
||
92 | $thisUrl = urlencode(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); |
||
93 | |||
94 | $userGroupInfo = '<br /><br /><table cellpadding="4" cellspacing="0" border="0">'; |
||
95 | $userGroupInfo .= '<thead><tr><th style="padding-bottom: 10px;">User Group</th><th>IP/Range</th></tr></thead>'; |
||
96 | $userGroupInfo .= '<tbody>'; |
||
97 | |||
98 | foreach ($userGroups as $group) { |
||
99 | $uid = $group['uid']; |
||
100 | $ips = implode(', ', $group['tx_aoeipauth_ip']); |
||
101 | |||
102 | $fullRecord = BackendUtility::getRecord('fe_groups', $uid); |
||
103 | $title = $fullRecord['title']; |
||
104 | |||
105 | $button = '<a title="Edit record" onclick="window.location.href=\'alt_doc.php?returnUrl=' . $thisUrl . |
||
106 | '&edit[fe_groups][' . $uid . ']=edit\'; return false;" href="#">' . |
||
107 | '<span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-open"> </span>' . |
||
108 | '</a>'; |
||
109 | |||
110 | $userGroupInfo .= '<tr><td style="padding: 0 20px 0 0;">' . $button . $title . '</td><td>' . $ips . '</td></tr>'; |
||
111 | } |
||
112 | |||
113 | $userGroupInfo .= '</tbody>'; |
||
114 | $userGroupInfo .= '</table>'; |
||
115 | |||
116 | $userGroupInfo .= '<br /><br />Your current IP is: <strong>' . $this->myIp . '</strong>'; |
||
117 | |||
118 | $reports[] = $this->objectManager->get('TYPO3\\CMS\\Reports\\Status', |
||
119 | 'IP Usergroup Authentication', |
||
120 | 'Some groups with automatic IP authentication were found.', |
||
121 | $userGroupInfo, |
||
122 | \TYPO3\CMS\Reports\Status::OK |
||
123 | ); |
||
124 | } |
||
125 | } |
||
126 | } |
||
127 |