Code Duplication    Length = 16-18 lines in 2 locations

example.php 1 location

@@ 4-21 (lines=18) @@
1
<?php
2
require_once('vendor/autoload.php');
3
4
class Foo
5
{
6
// Method to be executed in a thread
7
    public function bar($t)
8
    {
9
        echo "Starting thread #$t" . PHP_EOL;
10
11
        sleep(1 * rand(1, 5));
12
        for ($i = 0; $i < 10; $i++) {
13
            echo "Hello from thread #$t, i=$i" . PHP_EOL;
14
            sleep(1);
15
        }
16
        echo "Ending thread #$t" . PHP_EOL;
17
18
        // Note: this line below require the file "config/cacheconfig.php" exists
19
        return "$t: [[[[[[" . time() . "]]]]]]";
20
    }
21
}
22
23
try {
24
    $t = array();

example_pool.php 1 location

@@ 5-20 (lines=16) @@
2
3
require_once('vendor/autoload.php');
4
5
class Foo
6
{
7
// Method to be executed in a thread
8
    public function bar($t)
9
    {
10
        echo "Starting thread #$t" . PHP_EOL;
11
        sleep(1 * rand(1, 5));
12
        for ($i = 0; $i < 10; $i++) {
13
            echo "Hello from thread #$t, i=$i" . PHP_EOL;
14
            sleep(1);
15
        }
16
        echo "Ending thread #$t" . PHP_EOL;
17
18
        return uniqid("Thread_{$t}_");
19
    }
20
}
21
22
23
try {