Completed
Push — master ( 71f3ca...10d1fd )
by Thierry
01:44
created

Confirm::confirm()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Confirm.php - A confirm question for a Jaxon request
5
 *
6
 * This class adds a confirm question which is asked before calling a Jaxon function.
7
 *
8
 * @package jaxon-core
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
 */
13
14
namespace Jaxon\Dialog;
15
16
class Confirm implements Interfaces\Confirm
17
{
18
    /**
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