| Conditions | 13 | 
| Paths | 384 | 
| Total Lines | 62 | 
| Code Lines | 44 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
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  | 
            ||
| 40 | function wggithub_search($queryarray, $andor, $limit, $offset, $userid)  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 41 | {
 | 
            ||
| 42 | $ret = [];  | 
            ||
| 43 | $helper = Helper::getInstance();  | 
            ||
| 44 |     $repositoriesHandler = $helper->getHandler('Repositories');
 | 
            ||
| 45 |     $directoriesHandler  = $helper->getHandler('Directories');
 | 
            ||
| 46 | |||
| 47 | // search in table wggithub_repositories  | 
            ||
| 48 | $directories = [];  | 
            ||
| 49 | $directoriesAll = $directoriesHandler->getAll();  | 
            ||
| 50 |     foreach (\array_keys($directoriesAll) as $i) {
 | 
            ||
| 51 |         $directories[$directoriesAll[$i]->getVar('dir_name')] = $directoriesAll[$i]->getVar('dir_id');
 | 
            ||
| 52 | }  | 
            ||
| 53 | unset ($directoriesAll);  | 
            ||
| 54 | |||
| 55 | // search keywords  | 
            ||
| 56 | $elementCount = 0;  | 
            ||
| 57 |     if (\is_array($queryarray)) {
 | 
            ||
| 58 | $elementCount = \count($queryarray);  | 
            ||
| 59 | }  | 
            ||
| 60 |     if ($elementCount > 0) {
 | 
            ||
| 61 | $crKeywords = new \CriteriaCompo();  | 
            ||
| 62 |         for ($i = 0; $i  <  $elementCount; $i++) {
 | 
            ||
| 63 |             $crKeywords->add(new \Criteria('repo_name', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
 | 
            ||
| 64 | }  | 
            ||
| 65 | }  | 
            ||
| 66 | // search user(s)  | 
            ||
| 67 |     if ($userid && \is_array($userid)) {
 | 
            ||
| 68 |         $userid = array_map('intval', $userid);
 | 
            ||
| 69 | $crUser = new \CriteriaCompo();  | 
            ||
| 70 |         $crUser->add(new \Criteria('repo_submitter', '(' . \implode(',', $userid) . ')', 'IN'), 'OR');
 | 
            ||
| 71 |     } elseif (is_numeric($userid) && $userid > 0) {
 | 
            ||
| 72 | $crUser = new \CriteriaCompo();  | 
            ||
| 73 |         $crUser->add(new \Criteria('repo_submitter', $userid), 'OR');
 | 
            ||
| 74 | }  | 
            ||
| 75 | $crSearch = new \CriteriaCompo();  | 
            ||
| 76 |     if (isset($crKeywords)) {
 | 
            ||
| 77 | $crSearch->add($crKeywords, 'AND');  | 
            ||
| 78 | }  | 
            ||
| 79 |     if (isset($crUser)) {
 | 
            ||
| 80 | $crSearch->add($crUser, 'AND');  | 
            ||
| 81 | }  | 
            ||
| 82 |     if (0 === (int)$helper->getConfig('autoapproved')) {
 | 
            ||
| 83 |         $crSearch->add(new \Criteria('repo_approved', 1));
 | 
            ||
| 84 | }  | 
            ||
| 85 |     $crSearch->add(new \Criteria('repo_status', Constants::STATUS_UPTODATE));
 | 
            ||
| 86 | $crSearch->setStart($offset);  | 
            ||
| 87 | $crSearch->setLimit($limit);  | 
            ||
| 88 |     $crSearch->setSort('repo_datecreated');
 | 
            ||
| 89 |     $crSearch->setOrder('DESC');
 | 
            ||
| 90 | $repositoriesAll = $repositoriesHandler->getAll($crSearch);  | 
            ||
| 91 |     foreach (\array_keys($repositoriesAll) as $i) {
 | 
            ||
| 92 | $ret[] = [  | 
            ||
| 93 | 'image' => 'assets/icons/16/github.png',  | 
            ||
| 94 |             'link'   => 'index.php?op=show&dir_id=' . $directories[$repositoriesAll[$i]->getVar('repo_user')] . '&repo_id=' . $i,
 | 
            ||
| 95 |             'title'  => $repositoriesAll[$i]->getVar('repo_name') . ' (' . $repositoriesAll[$i]->getVar('repo_user') . ')',
 | 
            ||
| 96 |             'time'   => $repositoriesAll[$i]->getVar('repo_datecreated')
 | 
            ||
| 97 | ];  | 
            ||
| 98 | }  | 
            ||
| 99 | unset($crKeywords, $crUser, $crSearch, $repositoriesAll);  | 
            ||
| 100 | |||
| 101 | return $ret;  | 
            ||
| 102 | |||
| 104 | 
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.