Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
MentorRemover | |
0.00% |
0 / 18 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
removeMentor | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\Mentorship; |
4 | |
5 | use GrowthExperiments\Mentorship\Provider\IMentorWriter; |
6 | use GrowthExperiments\Mentorship\Provider\MentorProvider; |
7 | use MediaWiki\Context\IContextSource; |
8 | use MediaWiki\User\UserIdentity; |
9 | use StatusValue; |
10 | |
11 | class MentorRemover { |
12 | |
13 | private MentorProvider $mentorProvider; |
14 | private IMentorWriter $mentorWriter; |
15 | private ReassignMenteesFactory $reassignMenteesFactory; |
16 | |
17 | /** |
18 | * @param MentorProvider $mentorProvider |
19 | * @param IMentorWriter $mentorWriter |
20 | * @param ReassignMenteesFactory $reassignMenteesFactory |
21 | */ |
22 | public function __construct( |
23 | MentorProvider $mentorProvider, |
24 | IMentorWriter $mentorWriter, |
25 | ReassignMenteesFactory $reassignMenteesFactory |
26 | ) { |
27 | $this->mentorProvider = $mentorProvider; |
28 | $this->mentorWriter = $mentorWriter; |
29 | $this->reassignMenteesFactory = $reassignMenteesFactory; |
30 | } |
31 | |
32 | /** |
33 | * @param UserIdentity $performer |
34 | * @param UserIdentity $mentor |
35 | * @param string $reason |
36 | * @param IContextSource $context |
37 | * @return StatusValue |
38 | */ |
39 | public function removeMentor( |
40 | UserIdentity $performer, |
41 | UserIdentity $mentor, |
42 | string $reason, |
43 | IContextSource $context |
44 | ): StatusValue { |
45 | $status = $this->mentorWriter->removeMentor( |
46 | $this->mentorProvider->newMentorFromUserIdentity( $mentor ), |
47 | $performer, |
48 | $reason |
49 | ); |
50 | if ( $status->isOK() ) { |
51 | $this->reassignMenteesFactory->newReassignMentees( |
52 | $performer, |
53 | $mentor, |
54 | $context |
55 | )->reassignMentees( |
56 | 'growthexperiments-quit-mentorship-reassign-mentees-log-message-removed', |
57 | $performer->getName() |
58 | ); |
59 | } |
60 | return $status; |
61 | } |
62 | } |