Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CardWrapper | |
0.00% |
0 / 30 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
render | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\HomepageModules\SuggestedEditsComponents; |
4 | |
5 | use GrowthExperiments\NewcomerTasks\Task\TaskSet; |
6 | use OOUI\Tag; |
7 | |
8 | class CardWrapper { |
9 | |
10 | /** @var TaskSet|\StatusValue */ |
11 | private $taskSet; |
12 | |
13 | /** @var \MessageLocalizer */ |
14 | private $messageLocalizer; |
15 | |
16 | /** @var string */ |
17 | private $dir; |
18 | |
19 | /** @var bool */ |
20 | private $topicMatching; |
21 | private bool $topicMatchModeIsAND; |
22 | |
23 | /** @var NavigationWidgetFactory */ |
24 | private $navigationWidgetFactory; |
25 | |
26 | /** @var bool */ |
27 | private $isDesktop; |
28 | |
29 | /** |
30 | * @param \MessageLocalizer $messageLocalizer |
31 | * @param bool $topicMatching |
32 | * @param bool $topicMatchModeIsAND |
33 | * @param string $dir |
34 | * @param TaskSet|\StatusValue $taskSet |
35 | * @param NavigationWidgetFactory $navigationWidgetFactory |
36 | * @param bool $isDesktop |
37 | */ |
38 | public function __construct( |
39 | \MessageLocalizer $messageLocalizer, bool $topicMatching, bool $topicMatchModeIsAND, string $dir, $taskSet, |
40 | NavigationWidgetFactory $navigationWidgetFactory, bool $isDesktop |
41 | ) { |
42 | $this->taskSet = $taskSet; |
43 | $this->messageLocalizer = $messageLocalizer; |
44 | $this->dir = $dir; |
45 | $this->topicMatching = $topicMatching; |
46 | $this->topicMatchModeIsAND = $topicMatchModeIsAND; |
47 | $this->navigationWidgetFactory = $navigationWidgetFactory; |
48 | $this->isDesktop = $isDesktop; |
49 | } |
50 | |
51 | /** |
52 | * @return string |
53 | * @throws \OOUI\Exception |
54 | */ |
55 | public function render() { |
56 | $card = CardWidgetFactory::newFromTaskSet( |
57 | $this->messageLocalizer, |
58 | $this->topicMatching, |
59 | $this->topicMatchModeIsAND, |
60 | $this->dir, |
61 | $this->taskSet |
62 | ); |
63 | $suggestedEditsClass = ( new Tag( 'div' ) ) |
64 | ->addClasses( [ 'suggested-edits-card' ] ) |
65 | ->appendContent( $card ); |
66 | $contents = [ $suggestedEditsClass ]; |
67 | if ( $this->isDesktop ) { |
68 | $contents = [ |
69 | $this->navigationWidgetFactory->getPreviousNextButtonHtml( 'Previous' ), |
70 | $suggestedEditsClass, |
71 | $this->navigationWidgetFactory->getPreviousNextButtonHtml( 'Next' ) |
72 | ]; |
73 | } |
74 | return ( new Tag( 'div' ) )->addClasses( [ |
75 | 'suggested-edits-card-wrapper', |
76 | $card instanceof EditCardWidget ? '' : 'pseudo-card' |
77 | ] )->appendContent( |
78 | $contents |
79 | ); |
80 | } |
81 | } |