| Conditions | 7 |
| Paths | 10 |
| Total Lines | 59 |
| Code Lines | 34 |
| 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 |
||
| 15 | public static function getLpSubscription( |
||
| 16 | array $lpInfo, |
||
| 17 | int $studentId, |
||
| 18 | int $courseId, |
||
| 19 | int $sessionId = 0 |
||
| 20 | ): string { |
||
| 21 | $em = Database::getManager(); |
||
| 22 | |||
| 23 | if ($lpInfo['subscribe_users']) { |
||
| 24 | $itemRepo = $em->getRepository(CItemProperty::class); |
||
| 25 | $itemProperty = $itemRepo->findByUserSuscribedToItem( |
||
| 26 | 'learnpath', |
||
| 27 | $lpInfo['iid'], |
||
| 28 | $studentId, |
||
| 29 | $courseId, |
||
| 30 | $sessionId |
||
| 31 | ); |
||
| 32 | |||
| 33 | if (null === $itemProperty) { |
||
| 34 | $userGroups = GroupManager::getAllGroupPerUserSubscription($studentId, $courseId); |
||
| 35 | |||
| 36 | foreach ($userGroups as $groupInfo) { |
||
| 37 | $itemProperty = $itemRepo->findByGroupSuscribedToLp( |
||
| 38 | 'learnpath', |
||
| 39 | $lpInfo['iid'], |
||
| 40 | $groupInfo['iid'], |
||
| 41 | $courseId, |
||
| 42 | $sessionId |
||
| 43 | ); |
||
| 44 | |||
| 45 | if (null !== $itemProperty) { |
||
| 46 | break; |
||
| 47 | } |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | if (null === $itemProperty) { |
||
| 52 | return '-'; |
||
| 53 | } |
||
| 54 | |||
| 55 | return "{$itemProperty->getInsertUser()->getCompleteName()}<br>" |
||
| 56 | .Display::tag( |
||
| 57 | 'small', |
||
| 58 | api_convert_and_format_date($itemProperty->getInsertDate(), DATE_TIME_FORMAT_LONG) |
||
| 59 | ); |
||
| 60 | } |
||
| 61 | |||
| 62 | $subscriptionEvent = Event::findUserSubscriptionToCourse($studentId, $courseId, $sessionId); |
||
|
|
|||
| 63 | |||
| 64 | if (empty($subscriptionEvent)) { |
||
| 65 | return '-'; |
||
| 66 | } |
||
| 67 | |||
| 68 | $creator = api_get_user_entity($subscriptionEvent['default_user_id']); |
||
| 69 | |||
| 70 | return "{$creator->getCompleteName()}<br>" |
||
| 71 | .Display::tag( |
||
| 72 | 'small', |
||
| 73 | api_convert_and_format_date($subscriptionEvent['default_date'], DATE_TIME_FORMAT_LONG) |
||
| 74 | ); |
||
| 210 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.