Test Failed
Push — main ( c76fcf...a2096a )
by Bingo
14:02
created

TestTask   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 9
eloc 21
c 1
b 0
f 1
dl 0
loc 45
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 18 5
A serialize() 0 4 1
A getName() 0 3 1
A __construct() 0 3 1
A unserialize() 0 4 1
1
<?php
2
3
namespace Tests\Util;
4
5
use Jabe\Engine\Impl\Util\Concurrent\RunnableInterface;
6
7
class TestTask implements RunnableInterface, \Serializable
8
{
9
    private $name;
10
11
    public function __construct(string $name)
12
    {
13
        $this->name = $name;
14
    }
15
16
    public function serialize()
17
    {
18
        return json_encode([
19
            'name' => $this->name
20
        ]);
21
    }
22
23
    public function unserialize($data)
24
    {
25
        $json = json_decode($data);
26
        $this->name = $json->name;
27
    }
28
29
    public function getName(): string
30
    {
31
        return $this->name;
32
    }
33
34
    public function run(): void
35
    {
36
        $count = 0;
37
        $num = 2;
38
        $prime = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $prime is dead and can be removed.
Loading history...
39
        $divs;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $divs seems to be never defined.
Loading history...
40
        while ($count < 2000) {
41
            $divs = 0;
42
            for ($i = 1; $i <= $num; $i += 1) {
43
                if (($num % $i) == 0) {
44
                    $divs += 1;
45
                }
46
            }
47
            if ($divs < 3) {
48
                $prime = $num;
49
                $count += 1;
50
            }
51
            $num += 1;
52
        }
53
    }
54
}
55