| 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 analyseUses(&$reports) |
||
| 75 | { |
||
| 76 | /** @var \AOE\AoeIpauth\Domain\Service\FeEntityService $service */ |
||
| 77 | $service = $this->objectManager->get('AOE\\AoeIpauth\\Domain\\Service\\FeEntityService'); |
||
| 78 | |||
| 79 | $users = $service->findAllUsersWithIpAuthentication(); |
||
| 80 | |||
| 81 | if (empty($users)) { |
||
| 82 | // Message that no user group has IP authentication |
||
| 83 | $reports[] = $this->objectManager->get( |
||
| 84 | 'TYPO3\\CMS\\Reports\\Status', |
||
| 85 | 'IP User Authentication', |
||
| 86 | 'No users with IP authentication found', |
||
| 87 | 'No users 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 | $userInfo = '<br /><br /><table cellpadding="4" cellspacing="0" border="0">'; |
||
| 95 | $userInfo .= '<thead><tr><th style="padding-bottom: 10px;">User</th><th>IP/Range</th></tr></thead>'; |
||
| 96 | $userInfo .= '<tbody>'; |
||
| 97 | |||
| 98 | foreach ($users as $user) { |
||
| 99 | $uid = $user['uid']; |
||
| 100 | $ips = implode(', ', $user['tx_aoeipauth_ip']); |
||
| 101 | |||
| 102 | $fullRecord = BackendUtility::getRecord('fe_users', $uid); |
||
| 103 | $title = $fullRecord['username']; |
||
| 104 | |||
| 105 | $button = '<a title="Edit record" onclick="window.location.href=\'alt_doc.php?returnUrl=' . |
||
| 106 | $thisUrl . '&edit[fe_users][' . $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 | $userInfo .= '<tr><td style="padding: 0 20px 0 0;">' . $button . $title . '</td><td>' . $ips . '</td></tr>'; |
||
| 111 | } |
||
| 112 | |||
| 113 | $userInfo .= '</tbody>'; |
||
| 114 | $userInfo .= '</table>'; |
||
| 115 | |||
| 116 | $userInfo .= '<br /><br />Your current IP is: <strong>' . $this->myIp . '</strong>'; |
||
| 117 | |||
| 118 | $reports[] = $this->objectManager->get('TYPO3\\CMS\\Reports\\Status', |
||
| 119 | 'IP User Authentication', |
||
| 120 | 'Some users with automatic IP authentication were found.', |
||
| 121 | $userInfo, |
||
| 122 | \TYPO3\CMS\Reports\Status::OK |
||
| 123 | ); |
||
| 124 | } |
||
| 125 | } |
||
| 126 | } |
||
| 127 |