Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ChangeMentorFactory
0.00% covered (danger)
0.00%
0 / 15
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 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 newChangeMentor
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace GrowthExperiments\Mentorship;
4
5use GrowthExperiments\Mentorship\Store\MentorStore;
6use MediaWiki\User\UserFactory;
7use MediaWiki\User\UserIdentity;
8use Psr\Log\LoggerInterface;
9use Wikimedia\Rdbms\IConnectionProvider;
10
11class ChangeMentorFactory {
12
13    private LoggerInterface $logger;
14    private MentorManager $mentorManager;
15    private MentorStore $mentorStore;
16    private UserFactory $userFactory;
17    private IConnectionProvider $connectionProvider;
18
19    /**
20     * @param LoggerInterface $logger
21     * @param MentorManager $mentorManager
22     * @param MentorStore $mentorStore
23     * @param UserFactory $userFactory
24     * @param IConnectionProvider $connectionProvider
25     */
26    public function __construct(
27        LoggerInterface $logger,
28        MentorManager $mentorManager,
29        MentorStore $mentorStore,
30        UserFactory $userFactory,
31        IConnectionProvider $connectionProvider
32    ) {
33        $this->logger = $logger;
34        $this->mentorManager = $mentorManager;
35        $this->mentorStore = $mentorStore;
36        $this->userFactory = $userFactory;
37        $this->connectionProvider = $connectionProvider;
38    }
39
40    /**
41     * @param UserIdentity $mentee
42     * @param UserIdentity $performer
43     * @return ChangeMentor
44     */
45    public function newChangeMentor(
46        UserIdentity $mentee,
47        UserIdentity $performer
48    ): ChangeMentor {
49        return new ChangeMentor(
50            $mentee,
51            $performer,
52            $this->logger,
53            $this->mentorManager->getMentorForUserIfExists( $mentee ),
54            $this->mentorManager,
55            $this->mentorStore,
56            $this->userFactory,
57            $this->connectionProvider
58        );
59    }
60}