Completed
Pull Request — master (#10)
by Alice
03:35
created

TestThread   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDependencies() 0 3 1
A getMethodName() 0 3 1
A __construct() 0 4 1
A process() 0 7 1
1
<?php
2
3
namespace Wonderland\Thread\Example\SelfManaging;
4
5
use Wonderland\Thread\AbstractThread;
6
7
class TestThread extends AbstractThread {
8
9
    /**
10
     * @var array
11
     */
12
    private $dependencies;
13
14
    /**
15
     * TestThread constructor.
16
     *
17
     * @param string $processName
18
     * @param        $dependencies
19
     */
20
    public function __construct(string $processName, $dependencies)
21
    {
22
        parent::__construct($processName);
23
        $this->dependencies = $dependencies;
24
    }
25
26
    /**
27
     * @param $processName
28
     * @param $date
29
     * @return int
30
     */
31
    protected function process($processName, $date)
32
    {
33
        echo $processName . " " . $date . PHP_EOL;
34
35
        sleep(1);
36
37
        return self::EXIT_STATUS_SUCCESS;
38
    }
39
40
    /**
41
     * Return the name of the method to process during the thread
42
     *
43
     * @return string
44
     */
45
    protected function getMethodName(): string
46
    {
47
        return 'process';
48
    }
49
50
    /**
51
     * Return the list of dependencies that will be passed as parameters of the method referenced by getMethodName
52
     *
53
     * @return array
54
     */
55
    protected function getDependencies(): array
56
    {
57
        return $this->dependencies;
58
    }
59
}