Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
NoResultsCardWidget
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace GrowthExperiments\HomepageModules\SuggestedEditsComponents;
4
5use OOUI\Tag;
6use OOUI\Widget;
7
8class NoResultsCardWidget extends Widget {
9
10    /**
11     * @param array $config Configuration options
12     *   - MessageLocalizer $config['localizer']
13     *   - bool $config['topicMatching'] Whether topic matching is enabled
14     *   - any option understood by Widget
15     */
16    public function __construct( array $config = [] ) {
17        parent::__construct( $config );
18        /** @var \MessageLocalizer $localizer */
19        $localizer = $config['localizer'];
20        $noResultsDescriptionText = 'growthexperiments-homepage-suggestededits-select-other-difficulty';
21        if ( $config['topicMatching'] ) {
22            $noResultsDescriptionText = 'growthexperiments-homepage-suggestededits-select-other-topics-difficulty';
23            if ( $config['topicMatchModeIsAND'] ) {
24                $noResultsDescriptionText = 'growthexperiments-homepage-suggestededits-select-other-topic-mode';
25            }
26        }
27        $this->appendContent(
28            ( new Tag( 'div' ) )->addClasses( [ 'se-card-no-results' ] )
29            ->appendContent(
30                ( new Tag( 'h3' ) )->addClasses( [ 'se-card-title' ] )
31                ->appendContent( $localizer->msg( 'growthexperiments-homepage-suggestededits-no-results' )->text() ),
32                ( new Tag( 'div' ) )->addClasses( [ 'se-card-image' ] ),
33                ( new Tag( 'p' ) )->addClasses( [ 'se-card-text' ] )
34                    ->appendContent( $localizer->msg( $noResultsDescriptionText )->text() )
35            )
36        );
37    }
38}