Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
CardWidgetFactory | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
newFromTaskSet | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\HomepageModules\SuggestedEditsComponents; |
4 | |
5 | use GrowthExperiments\NewcomerTasks\Task\TaskSet; |
6 | use OOUI\Widget; |
7 | |
8 | class CardWidgetFactory { |
9 | |
10 | /** |
11 | * @param \MessageLocalizer $messageLocalizer |
12 | * @param bool $topicMatching |
13 | * @param bool $topicMatchModeIsAND |
14 | * @param string $dir |
15 | * @param TaskSet|\StatusValue $taskSet |
16 | * @return Widget |
17 | */ |
18 | public static function newFromTaskSet( |
19 | \MessageLocalizer $messageLocalizer, bool $topicMatching, bool $topicMatchModeIsAND, string $dir, $taskSet |
20 | ): Widget { |
21 | if ( $taskSet instanceof TaskSet ) { |
22 | if ( $taskSet->count() ) { |
23 | return new EditCardWidget( [ |
24 | 'task' => $taskSet[0], |
25 | 'dir' => $dir |
26 | ] ); |
27 | } else { |
28 | return new NoResultsCardWidget( [ |
29 | 'localizer' => $messageLocalizer, |
30 | 'topicMatching' => $topicMatching, |
31 | 'topicMatchModeIsAND' => $topicMatchModeIsAND |
32 | ] ); |
33 | } |
34 | } |
35 | return new ErrorCardWidget( [ 'localizer' => $messageLocalizer ] ); |
36 | } |
37 | } |