nl()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Modulebuilder\Files;
4
5
/* The 'nl' function */
6
/**
7
 * @param int $tabs
8
 *
9
 * @return string
10
 */
11
function nl($tabs = 0)
12
{
13
    $r = "\n";
14
    for ($i = 0; $i < $tabs; ++$i) {
15
        $r .= '   ';
16
    }
17
18
    return $r;
19
}
20
21
/* Usage example */
22
$show_table = true;
23
24
echo '<!doctype html>';
25
echo nl() . '<html>' . nl(1) . '<head>' . nl(2) . '<title>This is a title</title>' . nl(1) . '</head>' . nl(1) . '<body>' . nl(2) . '<div id="some_container">';
26
if ($show_table) {
0 ignored issues
show
introduced by
The condition $show_table is always true.
Loading history...
27
    echo nl(3) . '<table>' . nl(4) . '<tr>' . nl(5) . '<td>This is a cell in a table</td>' . nl(4) . '</tr>' . nl(3) . '</table>';
28
}
29
echo nl(2) . '</div><!--some_container-->' . nl(2) . '<p>This is some text in a paragraph</p>' . nl(1) . '</body>' . nl() . '</html>';
30
?>
31
<!doctype html>
32
<html>
33
<head>
34
    <title>This is a title</title>
35
</head>
36
<body>
37
<div id="some_container">
38
    <table>
39
        <tr>
40
            <td>This is a cell in a table</td>
41
        </tr>
42
    </table>
43
</div><!--some_container-->
44
<p>This is some text in a paragraph</p>
45
</body>
46
</html>
47