anonymous()
last analyzed

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
1
<?php
2
3
require dirname(__DIR__, 2) . "/vendor/autoload.php";
4
5
use WorkCode\WCRouter\WCRouter;
0 ignored issues
show
Bug introduced by
The type WorkCode\WCRouter\WCRouter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
define("BASE", "https://www.localhost/workcode/wcrouter/exemple/controller");
8
$router = new WCRouter(BASE);
9
10
/**
11
 * GET httpMethod
12
 */
13
$router->get("/", function ($data) {
14
    $data = ["realHttp" => $_SERVER["REQUEST_METHOD"]] + $data;
15
    echo "<h1>GET :: Spoofing</h1>", "<pre>", print_r($data, true), "</pre>";
0 ignored issues
show
Bug introduced by
Are you sure print_r($data, true) of type string|true can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

15
    echo "<h1>GET :: Spoofing</h1>", "<pre>", /** @scrutinizer ignore-type */ print_r($data, true), "</pre>";
Loading history...
16
});
17
18
/**
19
 * POST httpMethod
20
 */
21
$router->post("/", function ($data) {
22
    $data = ["realHttp" => $_SERVER["REQUEST_METHOD"]] + $data;
23
    echo "<h1>POST :: Spoofing</h1>", "<pre>", print_r($data, true), "</pre>";
0 ignored issues
show
Bug introduced by
Are you sure print_r($data, true) of type string|true can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

23
    echo "<h1>POST :: Spoofing</h1>", "<pre>", /** @scrutinizer ignore-type */ print_r($data, true), "</pre>";
Loading history...
24
});
25
26
/**
27
 * PUT spoofing and httpMethod
28
 */
29
$router->put("/", function ($data) {
30
    $data = ["realHttp" => $_SERVER["REQUEST_METHOD"]] + $data;
31
    echo "<h1>PUT :: Spoofing</h1>", "<pre>", print_r($data, true), "</pre>";
0 ignored issues
show
Bug introduced by
Are you sure print_r($data, true) of type string|true can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
    echo "<h1>PUT :: Spoofing</h1>", "<pre>", /** @scrutinizer ignore-type */ print_r($data, true), "</pre>";
Loading history...
32
});
33
34
/**
35
 * PATCH spoofing and httpMethod
36
 */
37
$router->patch("/", function ($data) {
38
    $data = ["realHttp" => $_SERVER["REQUEST_METHOD"]] + $data;
39
    echo "<h1>PATCH :: Spoofing</h1>", "<pre>", print_r($data, true), "</pre>";
0 ignored issues
show
Bug introduced by
Are you sure print_r($data, true) of type string|true can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
    echo "<h1>PATCH :: Spoofing</h1>", "<pre>", /** @scrutinizer ignore-type */ print_r($data, true), "</pre>";
Loading history...
40
});
41
42
/**
43
 * DELETE spoofing and httpMethod
44
 */
45
$router->delete("/", function ($data) {
46
    $data = ["realHttp" => $_SERVER["REQUEST_METHOD"]] + $data;
47
    echo "<h1>DELETE :: Spoofing</h1>", "<pre>", print_r($data, true), "</pre>";
0 ignored issues
show
Bug introduced by
Are you sure print_r($data, true) of type string|true can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
    echo "<h1>DELETE :: Spoofing</h1>", "<pre>", /** @scrutinizer ignore-type */ print_r($data, true), "</pre>";
Loading history...
48
});
49
50
$router->dispatch();
51
?>
52
53
<form action="" method="POST">
54
    <select name="_method">
55
        <option value="POST">POST</option>
56
        <option value="PUT">PUT</option>
57
        <option value="PATCH">PATCH</option>
58
        <option value="DELETE">DELETE</option>
59
    </select>
60
61
    <input type="text" name="first_name" value="Denis"/>
62
    <input type="text" name="last_name" value="Lumerk"/>
63
    <input type="text" name="email" value="[email protected]"/>
64
65
    <button>WorkCode</button>
66
</form>