Code Duplication    Length = 23-31 lines in 5 locations

PHPDaemon/Clients/Redis/Examples/SimpleRequest.php 1 location

@@ 59-89 (lines=31) @@
56
     * Called when request iterated.
57
     * @return integer Status.
58
     */
59
    public function run()
60
    {
61
        try {
62
            $this->header('Content-Type: text/html');
63
        } catch (\Exception $e) {
64
        }
65
66
        ?>
67
        <!DOCTYPE html>
68
        <html>
69
        <head>
70
            <meta charset="UTF-8">
71
            <title>Clients\Redis Simple example</title>
72
        </head>
73
        <body>
74
75
        <?php
76
        if ($r = $this->job->getResult('testquery')) {
77
            echo '<h1>It works! Be happy! ;-)</h1>Result of query: <pre>';
78
            var_dump($r);
79
            echo '</pre>';
80
        } else {
81
            echo '<h1>Something went wrong! We have no result.</h1>';
82
        }
83
        echo '<br />Request (http) took: ' . round(microtime(true) - $this->attrs->server['REQUEST_TIME_FLOAT'], 6);
84
85
        ?>
86
        </body>
87
        </html>
88
89
        <?php
90
91
    }
92
}

PHPDaemon/Examples/ExampleGibson.php 1 location

@@ 80-105 (lines=26) @@
77
     * Called when request iterated.
78
     * @return integer Status.
79
     */
80
    public function run()
81
    {
82
        try {
83
            $this->header('Content-Type: text/html');
84
        } catch (\Exception $e) {
85
        }
86
        ?>
87
        <!DOCTYPE html>
88
        <html xmlns="http://www.w3.org/1999/xhtml">
89
        <head>
90
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
91
            <title>Example with Gibson</title>
92
        </head>
93
        <body>
94
        <?php
95
        if ($r = $this->job->getResult('testquery')) {
96
            echo '<h1>It works! Be happy! ;-)</h1>Result of query: <pre>';
97
            var_dump($r);
98
            echo '</pre>';
99
        } else {
100
            echo '<h1>Something went wrong! We have no result...</h1>';
101
        }
102
        echo '<br />Request (http) took: ' . round(microtime(true) - $this->attrs->server['REQUEST_TIME_FLOAT'], 6);
103
        ?>
104
        </body>
105
        </html>
106
        <?php
107
108
    }

PHPDaemon/Examples/ExampleWithMemcache.php 1 location

@@ 69-91 (lines=23) @@
66
 * Called when request iterated.
67
 * @return integer Status.
68
 */
69
public function run()
70
{
71
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
72
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
73
<html xmlns="http://www.w3.org/1999/xhtml">
74
<head>
75
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
76
    <title>Example with Memcache</title>
77
</head>
78
<body>
79
<?php
80
if ($r = $this->job->getResult('testquery')) {
81
    echo '<h1>It works! Be happy! ;-)</h1>Result of query: <pre>';
82
    var_dump($r);
83
    echo '</pre>';
84
} else {
85
    echo '<h1>Something went wrong! We have no result.</h1>';
86
}
87
echo '<br />Request (http) took: ' . round(microtime(true) - $this->attrs->server['REQUEST_TIME_FLOAT'], 6);
88
?>
89
</body>
90
</html>
91
<?php
92
93
}
94
}

PHPDaemon/Examples/ExampleWithMongo.php 1 location

@@ 73-100 (lines=28) @@
70
     * Called when request iterated.
71
     * @return integer Status.
72
     */
73
    public function run()
74
    {
75
        try {
76
            $this->header('Content-Type: text/html');
77
        } catch (\Exception $e) {
78
        }
79
        ?>
80
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
81
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
82
        <html xmlns="http://www.w3.org/1999/xhtml">
83
        <head>
84
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
85
            <title>Example with Mongo</title>
86
        </head>
87
        <body>
88
        <?php
89
        if ($r = $this->job->getResult('testquery')) {
90
            echo '<h1>It works! Be happy! ;-)</h1>Result of query: <pre>';
91
            var_dump($r);
92
            echo '</pre>';
93
        } else {
94
            echo '<h1>Something went wrong! We have no result.</h1>';
95
        }
96
        echo '<br />Request (http) took: ' . round(microtime(true) - $this->attrs->server['REQUEST_TIME_FLOAT'], 6);
97
        ?>
98
        </body>
99
        </html>
100
        <?php
101
102
    }
103
}

PHPDaemon/Examples/ExampleWithPostgreSQL.php 1 location

@@ 71-101 (lines=31) @@
68
     * Called when request iterated.
69
     * @return integer Status.
70
     */
71
    public function run()
72
    {
73
        try {
74
            $this->header('Content-Type: text/html');
75
        } catch (\Exception $e) {
76
        }
77
        ?>
78
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
79
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
80
        <html xmlns="http://www.w3.org/1999/xhtml">
81
        <head>
82
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
83
            <title>Example with PostgreSQL</title>
84
        </head>
85
        <body>
86
        <?php
87
88
        if ($this->queryResult) {
89
            echo '<h1>It works! Be happy! ;-)</h1>Result of `SELECT 123 as integer, NULL as nul, \'test\' as string`: <pre>';
90
            var_dump($this->queryResult);
91
            echo '</pre>';
92
        } else {
93
            echo '<h1>Something went wrong! We have no result.</h1>';
94
        }
95
96
        echo '<br />Request (http) took: ' . round(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], 6);
97
98
        ?>
99
        </body>
100
        </html>
101
        <?php
102
103
    }
104
}