Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
CardWidgetFactory
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 newFromTaskSet
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace GrowthExperiments\HomepageModules\SuggestedEditsComponents;
4
5use GrowthExperiments\NewcomerTasks\Task\TaskSet;
6use OOUI\Widget;
7
8class 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}