Completed
Branch BUG-10375-migrations-not-repor... (1e9646)
by
unknown
62:53 queued 49:42
created

TicketSelectorIframe   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 63
rs 10
c 1
b 0
f 1
wmc 2
lcom 0
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 52 2
1
<?php
2
namespace EventEspresso\modules\ticket_selector;
3
4
use EventEspresso\core\libraries\iframe_display\Iframe;
5
6
if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
    exit( 'No direct script access allowed' );
8
}
9
10
11
12
/**
13
 * Class TicketSelectorIframe
14
 * Description
15
 *
16
 * @package       Event Espresso
17
 * @subpackage    core
18
 * @author        Brent Christensen
19
 * @since         $VID:$
20
 */
21
class TicketSelectorIframe extends Iframe
22
{
23
24
    /**
25
     * TicketSelectorIframe constructor.
26
     *
27
     * @throws \DomainException
28
     * @throws \EE_Error
29
     */
30
    public function __construct()
31
    {
32
        \EE_Registry::instance()->REQ->set_espresso_page( true );
33
        /** @type \EEM_Event $EEM_Event */
34
        $EEM_Event = \EE_Registry::instance()->load_model( 'Event' );
35
        $event = $EEM_Event->get_one_by_ID(
36
            \EE_Registry::instance()->REQ->get( 'event', 0 )
37
        );
38
        $ticket_selector = new DisplayTicketSelector();
39
        $ticket_selector->setIframe( true );
40
        parent::__construct(
41
            esc_html__( 'Ticket Selector', 'event_espresso' ),
42
            $ticket_selector->display( $event )
0 ignored issues
show
Bug introduced by
It seems like $event defined by $EEM_Event->get_one_by_I...->REQ->get('event', 0)) on line 35 can also be of type object<EE_Base_Class>; however, EventEspresso\modules\ti...cketSelector::display() does only seem to accept object<WP_Post>|integer|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Security Bug introduced by
It seems like $ticket_selector->display($event) targeting EventEspresso\modules\ti...cketSelector::display() can also be of type false; however, EventEspresso\core\libra...y\Iframe::__construct() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
43
        );
44
        $this->addStylesheets(
45
            apply_filters(
46
                'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
47
                array(
48
                    'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL
49
                                               . 'ticket_selector_embed.css?ver='
50
                                               . EVENT_ESPRESSO_VERSION,
51
                    'ticket_selector'       => TICKET_SELECTOR_ASSETS_URL
52
                                               . 'ticket_selector.css?ver='
53
                                               . EVENT_ESPRESSO_VERSION,
54
                ),
55
                $this
56
            )
57
        );
58
        if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) {
59
            $this->addStylesheets( array('site_theme' => '' ) );
60
        }
61
        $this->addScripts(
62
            apply_filters(
63
                'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
64
                array(
65
                    'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL
66
                                                      . 'ticket_selector_iframe_embed.js?ver='
67
                                                      . EVENT_ESPRESSO_VERSION,
68
                ),
69
                $this
70
            )
71
        );
72
        $this->addLocalizedVars(
73
            array(
74
                'ticket_selector_iframe' => true,
75
                'EEDTicketSelectorMsg'   => __(
76
                    'Please choose at least one ticket before continuing.',
77
                    'event_espresso'
78
                ),
79
            )
80
        );
81
    }
82
83
}
84
// End of file TicketSelectorIframe.php
85
// Location: /TicketSelectorIframe.php