Modal   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A close() 0 6 1
A __construct() 0 11 1
1
<?php
2
3
namespace DM\AjaxCom\Responder;
4
5
class Modal extends AbstractResponder
6
{
7
    const OBJECT_IDENTIFIER = 'modal';
8
9
    const OPTION_TYPE = 'type';
10
    const OPTION_HTML = 'html';
11
    const OPTION_CLOSE = 'close';
12
    const OPTION_AUTOREMOVE = 'autoremove';
13
14
    const DEFAULT_TYPE = 'twitterbootstrap';
15
16
    /**
17
     * Constructor
18
     *
19
     * @param string $html HTML for a new modal or a jquery selector for an
20
     *                     existing modal
21
     * @param string $type Type of modal to create
22
     * @param bool $autoremove Remove the modal from the dom when it is closed
23
     */
24
    public function __construct($html, $type = self::DEFAULT_TYPE, $autoremove = true)
25
    {
26
        $this->registerOption(self::OPTION_HTML);
27
        $this->registerOption(self::OPTION_TYPE);
28
        $this->registerOption(self::OPTION_CLOSE);
29
        $this->registerOption(self::OPTION_AUTOREMOVE);
30
31
        $this->setOption(self::OPTION_HTML, $html);
32
        $this->setOption(self::OPTION_TYPE, $type);
33
        $this->setOption(self::OPTION_AUTOREMOVE, (bool)$autoremove);
34
    }
35
36
    /**
37
     * Close modal
38
     *
39
     * @return Modal
40
     */
41
    public function close()
42
    {
43
        $this->setOption(self::OPTION_CLOSE, true);
44
45
        return $this;
46
    }
47
}
48