| Conditions | 17 |
| Paths | > 20000 |
| Total Lines | 56 |
| Code Lines | 42 |
| 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 |
||
| 26 | public static function getSubstitutableVariables( |
||
| 27 | User $user, |
||
| 28 | Course $course, |
||
| 29 | Session $session = null, |
||
| 30 | $domain = '', |
||
| 31 | $ltiVersion = self::V_1P1, |
||
| 32 | ImsLtiTool $tool |
||
| 33 | ) { |
||
| 34 | $isLti1p3 = $ltiVersion === self::V_1P3; |
||
| 35 | |||
| 36 | return [ |
||
| 37 | '$User.id' => $user->getId(), |
||
| 38 | '$User.image' => $isLti1p3 ? ['claim' => 'sub'] : ['user_image'], |
||
| 39 | '$User.username' => $user->getUsername(), |
||
| 40 | '$User.org' => false, |
||
| 41 | '$User.scope.mentor' => $isLti1p3 ? ['claim' => '/claim/role_scope_mentor'] : ['role_scope_mentor'], |
||
| 42 | |||
| 43 | '$Person.sourcedId' => $isLti1p3 |
||
| 44 | ? self::getPersonSourcedId($domain, $user) |
||
| 45 | : "$domain:".ImsLtiPlugin::getLaunchUserIdClaim($tool, $user), |
||
| 46 | '$Person.name.full' => $user->getFullname(), |
||
| 47 | '$Person.name.family' => $user->getLastname(), |
||
| 48 | '$Person.name.given' => $user->getFirstname(), |
||
| 49 | '$Person.address.street1' => $user->getAddress(), |
||
| 50 | '$Person.phone.primary' => $user->getPhone(), |
||
| 51 | '$Person.email.primary' => $user->getEmail(), |
||
| 52 | |||
| 53 | '$CourseSection.sourcedId' => $isLti1p3 |
||
| 54 | ? ['claim' => '/claim/lis', 'property' => 'course_section_sourcedid'] |
||
| 55 | : ['lis_course_section_sourcedid'], |
||
| 56 | '$CourseSection.label' => $course->getCode(), |
||
| 57 | '$CourseSection.title' => $course->getTitle(), |
||
| 58 | '$CourseSection.longDescription' => $session && $session->getShowDescription() |
||
| 59 | ? $session->getDescription() |
||
| 60 | : false, |
||
| 61 | '$CourseSection.timeFrame.begin' => $session && $session->getDisplayStartDate() |
||
| 62 | ? $session->getDisplayStartDate()->format(DateTime::ATOM) |
||
| 63 | : '$CourseSection.timeFrame.begin', |
||
| 64 | '$CourseSection.timeFrame.end' => $session && $session->getDisplayEndDate() |
||
| 65 | ? $session->getDisplayEndDate()->format(DateTime::ATOM) |
||
| 66 | : '$CourseSection.timeFrame.end', |
||
| 67 | |||
| 68 | '$Membership.role' => $isLti1p3 ? ['claim' => '/claim/roles'] : ['roles'], |
||
| 69 | |||
| 70 | '$Result.sourcedGUID' => $isLti1p3 ? ['claim' => 'sub'] : ['lis_result_sourcedid'], |
||
| 71 | '$Result.sourcedId' => $isLti1p3 ? ['claim' => 'sub'] : ['lis_result_sourcedid'], |
||
| 72 | |||
| 73 | '$ResourceLink.id' => $isLti1p3 |
||
| 74 | ? ['claim' => '/claim/resource_link', 'property' => 'id'] |
||
| 75 | : ['resource_link_id'], |
||
| 76 | '$ResourceLink.title' => $isLti1p3 |
||
| 77 | ? ['claim' => '/claim/resource_link', 'property' => 'title'] |
||
| 78 | : ['resource_link_title'], |
||
| 79 | '$ResourceLink.description' => $isLti1p3 |
||
| 80 | ? ['claim' => '/claim/resource_link', 'property' => 'description'] |
||
| 81 | : ['resource_link_description'], |
||
| 82 | ]; |
||
| 241 |