Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
HomepageParserFunctions | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
mentorRender | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments; |
4 | |
5 | use GrowthExperiments\Mentorship\MentorManager; |
6 | use MediaWiki\Parser\Parser; |
7 | use MediaWiki\User\UserFactory; |
8 | |
9 | /** |
10 | * Class for handling parser functions introduced by GrowthExperiments |
11 | */ |
12 | class HomepageParserFunctions { |
13 | /** |
14 | * Handler for {{#mentor:Username}} |
15 | * |
16 | * @param UserFactory $userFactory |
17 | * @param MentorManager $mentorManager |
18 | * @param Parser $parser |
19 | * @param string $username Mentee's username |
20 | * |
21 | * @return string |
22 | */ |
23 | public static function mentorRender( |
24 | UserFactory $userFactory, |
25 | MentorManager $mentorManager, |
26 | Parser $parser, |
27 | $username |
28 | ): string { |
29 | $menteeUser = $userFactory->newFromName( $username ); |
30 | if ( $menteeUser === null ) { |
31 | return ''; |
32 | } |
33 | |
34 | $mentor = $mentorManager->getMentorForUserIfExists( |
35 | $menteeUser |
36 | ); |
37 | if ( $mentor === null ) { |
38 | return ''; |
39 | } |
40 | |
41 | return $mentor->getUserIdentity()->getName(); |
42 | } |
43 | } |