Passed
Push — master ( 0602c9...8f96ba )
by Thierry
02:02
created

Question   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A confirm() 0 9 2
1
<?php
2
3
/**
4
 * Question.php - A confirmation question for a Jaxon request
5
 *
6
 * This class adds a confirmation question which is asked before calling a Jaxon function.
7
 *
8
 * @package jaxon-core
0 ignored issues
show
Coding Style introduced by
Package name "jaxon-core" is not valid; consider "Jaxoncore" instead
Loading history...
9
 * @copyright 2016 Thierry Feuzeu <[email protected]>
10
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
11
 * @link https://github.com/jaxon-php/jaxon-core
12
 */
0 ignored issues
show
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
PHP version not specified
Loading history...
13
14
namespace Jaxon\Ui\Dialogs;
15
16
class Question implements \Jaxon\Contracts\Dialogs\Question
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Question
Loading history...
17
{
18
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $noScript should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $yesScript should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $question should have a doc-comment as per coding-style.
Loading history...
19
     * Get the script which makes a call only if the user answers yes to the given question
20
     *
21
     * @return string
22
     */
23
    public function confirm($question, $yesScript, $noScript)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
24
    {
25
        if(!$noScript)
26
        {
27
            return 'if(confirm(' . $question . ')){' . $yesScript . ';}';
28
        }
29
        else
30
        {
31
            return 'if(confirm(' . $question . ')){' . $yesScript . ';}else{' . $noScript . ';}';
32
        }
33
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
34
}
35