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

Confirm   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A confirm() 0 11 2
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