Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ReassignMenteesFactory
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 newReassignMentees
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace GrowthExperiments\Mentorship;
4
5use GrowthExperiments\Mentorship\Provider\MentorProvider;
6use GrowthExperiments\Mentorship\Store\MentorStore;
7use MediaWiki\Context\IContextSource;
8use MediaWiki\JobQueue\JobQueueGroupFactory;
9use MediaWiki\Language\FormatterFactory;
10use MediaWiki\Logger\LoggerFactory;
11use MediaWiki\User\UserIdentity;
12use Wikimedia\Rdbms\ILoadBalancer;
13
14class ReassignMenteesFactory {
15
16    private ILoadBalancer $dbLoadBalancer;
17    private MentorManager $mentorManager;
18    private MentorProvider $mentorProvider;
19    private MentorStore $mentorStore;
20    private ChangeMentorFactory $changeMentorFactory;
21    private JobQueueGroupFactory $jobQueueGroupFactory;
22    private FormatterFactory $formatterFactory;
23
24    /**
25     * @param ILoadBalancer $dbLoadBalancer
26     * @param MentorManager $mentorManager
27     * @param MentorProvider $mentorProvider
28     * @param MentorStore $mentorStore
29     * @param ChangeMentorFactory $changeMentorFactory
30     * @param JobQueueGroupFactory $jobQueueGroupFactory
31     * @param FormatterFactory $formatterFactory
32     */
33    public function __construct(
34        ILoadBalancer $dbLoadBalancer,
35        MentorManager $mentorManager,
36        MentorProvider $mentorProvider,
37        MentorStore $mentorStore,
38        ChangeMentorFactory $changeMentorFactory,
39        JobQueueGroupFactory $jobQueueGroupFactory,
40        FormatterFactory $formatterFactory
41    ) {
42        $this->dbLoadBalancer = $dbLoadBalancer;
43        $this->mentorManager = $mentorManager;
44        $this->mentorProvider = $mentorProvider;
45        $this->mentorStore = $mentorStore;
46        $this->changeMentorFactory = $changeMentorFactory;
47        $this->jobQueueGroupFactory = $jobQueueGroupFactory;
48        $this->formatterFactory = $formatterFactory;
49    }
50
51    /**
52     * @param UserIdentity $performer
53     * @param UserIdentity $mentor
54     * @param IContextSource $context
55     * @return ReassignMentees
56     */
57    public function newReassignMentees(
58        UserIdentity $performer,
59        UserIdentity $mentor,
60        IContextSource $context
61    ): ReassignMentees {
62        $reassignMentees = new ReassignMentees(
63            $this->dbLoadBalancer->getConnection( DB_PRIMARY ),
64            $this->mentorManager,
65            $this->mentorProvider,
66            $this->mentorStore,
67            $this->changeMentorFactory,
68            $this->jobQueueGroupFactory,
69            $this->formatterFactory->getStatusFormatter( $context ),
70            $performer,
71            $mentor,
72            $context
73        );
74        $reassignMentees->setLogger( LoggerFactory::getInstance( 'GrowthExperiments' ) );
75        return $reassignMentees;
76    }
77}