Passed
Push — feature/code_improvement ( ee2f22...15c17b )
by Thierry
03:25 queued 42s
created

Question::confirm()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
cc 2
nc 2
nop 3
rs 9.9
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
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
13
14
namespace Jaxon\Utils\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 $question 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 $noScript 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)
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
    }
34
}
35