Completed
Pull Request — develop (#518)
by Agel_Nash
06:14
created

action_options.php ➔ getTemplates()   C

Complexity

Conditions 10
Paths 133

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 18
nc 133
nop 1
dl 0
loc 23
rs 5.2413
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0;
3
4
switch($installMode){
5
    case 0:
6
    case 2:
7
        $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci';
8
        $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
9
        $_POST['database_connection_charset'] = $database_charset;
10
        if(empty($_SESSION['databaseloginpassword']))
11
            $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword'];
12
        if(empty($_SESSION['databaseloginname']))
13
            $_SESSION['databaseloginname'] = $_POST['databaseloginname'];
14
        break;
15
    case 1:
16
        include $base_path . MGR_DIR . '/includes/config.inc.php';
17
        if (@ $conn = mysqli_connect($database_server, $database_user, $database_password)) {
18
            if (@ mysqli_query($conn, "USE {$dbase}")) {
19
                if (!$rs = mysqli_query($conn, "show session variables like 'collation_database'")) {
20
                    $rs = mysqli_query($conn, "show session variables like 'collation_server'");
21
                }
22
                if ($rs && $collation = mysqli_fetch_row($rs)) {
23
                    $database_collation = trim($collation[1]);
24
                }
25
            }
26
        }
27
        if (empty ($database_collation)) $database_collation = 'utf8_general_ci';
28
29
        $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
30
        if (!isset ($database_connection_charset) || empty ($database_connection_charset)) {
31
            $database_connection_charset = $database_charset;
32
        }
33
34
        if (!isset ($database_connection_method) || empty ($database_connection_method)) {
35
            $database_connection_method = 'SET CHARACTER SET';
36
            if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_connection_charset);
37
        }
38
        if ($database_connection_method != 'SET NAMES' && $database_connection_charset != $database_charset) {
39
            $database_connection_method = 'SET NAMES';
40
        }
41
42
        $_POST['database_name'] = $dbase;
43
        $_POST['tableprefix'] = $table_prefix;
44
        $_POST['database_connection_charset'] = $database_connection_charset;
45
        $_POST['database_connection_method'] = $database_connection_method;
46
        $_POST['databasehost'] = $database_server;
47
        $_SESSION['databaseloginname'] = $database_user;
48
        $_SESSION['databaseloginpassword'] = $database_password;
49
        break;
50
    default:
51
        throw new Exception('installmode is undefined');
52
}
53
54
$ph['install_language'] = $install_language;
55
$ph['manager_language'] = $manager_language;
56
$ph['installMode'] = $installMode;
57
$ph['database_name'] = trim($_POST['database_name'], '`');
58
$ph['tableprefix'] = $_POST['tableprefix'];
59
$ph['database_collation'] = $_POST['database_collation'];
60
$ph['database_connection_charset'] = $_POST['database_connection_charset'];
61
$ph['database_connection_method'] = $_POST['database_connection_method'];
62
$ph['databasehost'] = $_POST['databasehost'];
63
$ph['cmsadmin'] = trim($_POST['cmsadmin']);
64
$ph['cmsadminemail'] = trim($_POST['cmsadminemail']);
65
$ph['cmspassword'] = trim($_POST['cmspassword']);
66
$ph['cmspasswordconfirm'] = trim($_POST['cmspasswordconfirm']);
67
68
$ph['checked'] = isset ($_POST['installdata']) && $_POST['installdata'] == "1" ? 'checked' : '';
69
70
# load setup information file
71
include($base_path . 'install/setup.info.php');
72
$ph['templates'] = getTemplates($moduleTemplates);
73
$ph['tvs']       = getTVs($moduleTVs);
74
$ph['chunks']    = getChunks($moduleChunks);
75
$ph['modules']   = getModules($moduleModules);
76
$ph['plugins']   = getPlugins($modulePlugins);
77
$ph['snippets']  = getSnippets($moduleSnippets);
78
79
$ph['action'] = ($installMode == 1) ? 'mode' : 'connection';
80
81
$tpl = file_get_contents($base_path . 'install/actions/tpl_options.html');
82
$content = parse($tpl,$ph);
83
echo parse($content,$_lang,'[%','%]');
84
85
86
if( ! function_exists('getTemplates')) {
87
    /**
88
     * @param array $presets
89
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
90
     */
91
    function getTemplates($presets = array())
92
    {
93
        if (!count($presets)) {
94
            return '';
95
        }
96
        $selectedTemplates = isset ($_POST['template']) ? $_POST['template'] : array();
97
        $tpl = '<label><input type="checkbox" name="template[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
98
        $_ = array();
99
        $i = 0;
100
        $ph = array();
101
        foreach ($presets as $preset) {
102
            $ph['i'] = $i;
103
            $ph['name'] = isset($preset[0]) ? $preset[0] : '';
104
            $ph['desc'] = isset($preset[1]) ? $preset[1] : '';
105
            $ph['class'] = !in_array('sample', $preset[6]) ? 'toggle' : 'toggle demo';
106
            $ph['checked'] = in_array($i, $selectedTemplates) || (!isset($_POST['options_selected'])) ? 'checked' : '';
107
            $_[] = parse($tpl, $ph);
108
            $i++;
109
        }
110
        if (0 < count($_)) {
111
            return '<h3>[%templates%]</h3>' . join("\n", $_);
112
        }
113
    }
114
}
115
116 View Code Duplication
if( ! function_exists('getTVs')) {
117
    /**
118
     * @param array $presets
119
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
120
     */
121
    function getTVs($presets = array())
122
    {
123
        if (!count($presets)) {
124
            return '';
125
        }
126
        $selectedTvs = isset ($_POST['tv']) ? $_POST['tv'] : array();
127
        $tpl = '<label><input type="checkbox" name="tv[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+alterName+] <span class="description">([+desc+])</span></label><hr />';
128
        $_ = array();
129
        $i = 0;
130
        foreach ($presets as $preset) {
131
            $ph['i'] = $i;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$ph was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ph = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
132
            $ph['name'] = $preset[0];
0 ignored issues
show
Bug introduced by
The variable $ph does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
133
            $ph['alterName'] = $preset[1];
134
            $ph['desc'] = $preset[2];
135
            $ph['class'] = !in_array('sample', $preset[12]) ? 'toggle' : 'toggle demo';
136
            $ph['checked'] = in_array($i, $selectedTvs) || (!isset($_POST['options_selected'])) ? 'checked' : '';
137
            $_[] = parse($tpl, $ph);
138
            $i++;
139
        }
140
        if (0 < count($_)) {
141
            return '<h3>[%tvs%]</h3>' . join("\n", $_);
142
        }
143
    }
144
}
145
146 View Code Duplication
if( ! function_exists('getChunks')) {
147
    /**
148
     * display chunks
149
     *
150
     * @param array $presets
151
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
152
     */
153
    function getChunks($presets = array())
154
    {
155
        if (!count($presets)) {
156
            return '';
157
        }
158
        $selected = isset ($_POST['chunk']) ? $_POST['chunk'] : array();
159
        $tpl = '<label><input type="checkbox" name="chunk[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
160
        $_ = array();
161
        $i = 0;
162
        foreach ($presets as $preset) {
163
            $ph['i'] = $i;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$ph was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ph = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
164
            $ph['name'] = $preset[0];
0 ignored issues
show
Bug introduced by
The variable $ph does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
165
            $ph['desc'] = $preset[1];
166
            $ph['class'] = !in_array('sample', $preset[5]) ? 'toggle' : 'toggle demo';
167
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
168
            $_[] = parse($tpl, $ph);
169
            $i++;
170
        }
171
        if (0 < count($_)) {
172
            return '<h3>[%chunks%]</h3>' . join("\n", $_);
173
        }
174
    }
175
}
176
177 View Code Duplication
if( ! function_exists('getModules')) {
178
    /**
179
     * display modules
180
     *
181
     * @param array $presets
182
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
183
     */
184
    function getModules($presets = array())
185
    {
186
        if (!count($presets)) {
187
            return '';
188
        }
189
        $selected = isset ($_POST['module']) ? $_POST['module'] : array();
190
        $tpl = '<label><input type="checkbox" name="module[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
191
        $_ = array();
192
        $i = 0;
193
        foreach ($presets as $preset) {
194
            $ph['i'] = $i;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$ph was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ph = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
195
            $ph['name'] = $preset[0];
0 ignored issues
show
Bug introduced by
The variable $ph does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
196
            $ph['desc'] = $preset[1];
197
            $ph['class'] = !in_array('sample', $preset[7]) ? 'toggle' : 'toggle demo';
198
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
199
            $_[] = parse($tpl, $ph);
200
            $i++;
201
        }
202
        if (0 < count($_)) {
203
            return '<h3>[%modules%]</h3>' . join("\n", $_);
204
        }
205
    }
206
}
207
208 View Code Duplication
if( ! function_exists('getPlugins')) {
209
    /**
210
     * display plugins
211
     *
212
     * @param array $presets
213
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
214
     */
215
    function getPlugins($presets = array())
216
    {
217
        if (!count($presets)) {
218
            return '';
219
        }
220
        $selected = isset ($_POST['plugin']) ? $_POST['plugin'] : array();
221
        $tpl = '<label><input type="checkbox" name="plugin[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
222
        $_ = array();
223
        $i = 0;
224
        foreach ($presets as $preset) {
225
            $ph['i'] = $i;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$ph was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ph = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
226
            $ph['name'] = $preset[0];
0 ignored issues
show
Bug introduced by
The variable $ph does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
227
            $ph['desc'] = $preset[1];
228
            if (is_array($preset[8])) {
229
                $ph['class'] = !in_array('sample', $preset[8]) ? 'toggle' : 'toggle demo';
230
            } else {
231
                $ph['class'] = 'toggle demo';
232
            }
233
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
234
            $_[] = parse($tpl, $ph);
235
            $i++;
236
        }
237
        if (0 < count($_)) {
238
            return '<h3>[%plugins%]</h3>' . join("\n", $_);
239
        }
240
    }
241
}
242
243 View Code Duplication
if( ! function_exists('getSnippets')) {
244
    /**
245
     * display snippets
246
     *
247
     * @param array $presets
248
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
249
     */
250
    function getSnippets($presets = array())
251
    {
252
        if (!count($presets)) {
253
            return '';
254
        }
255
        $selected = isset ($_POST['snippet']) ? $_POST['snippet'] : array();
256
        $tpl = '<label><input type="checkbox" name="snippet[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
257
        $_ = array();
258
        $i = 0;
259
        foreach ($presets as $preset) {
260
            $ph['i'] = $i;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$ph was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ph = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
261
            $ph['name'] = $preset[0];
0 ignored issues
show
Bug introduced by
The variable $ph does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
262
            $ph['desc'] = $preset[1];
263
            $ph['class'] = !in_array('sample', $preset[5]) ? 'toggle' : 'toggle demo';
264
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
265
            $_[] = parse($tpl, $ph);
266
            $i++;
267
        }
268
        if (0 < count($_)) {
269
            return '<h3>[%snippets%]</h3>' . join("\n", $_);
270
        }
271
    }
272
}
273