SynchronousManager   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 41
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addTask() 0 6 1
A tick() 0 14 3
1
<?php
2
3
namespace AsyncPHP\Doorman\Manager;
4
5
use AsyncPHP\Doorman\Handler;
6
use AsyncPHP\Doorman\Manager;
7
use AsyncPHP\Doorman\Task;
8
9
class SynchronousManager implements Manager
10
{
11
    /**
12
     * @var Task[]
13
     */
14
    protected $waiting = array();
15
16
    /**
17
     * @inheritdoc
18
     *
19
     * @param Task $task
20
     *
21
     * @return $this
22
     */
23
    public function addTask(Task $task)
24
    {
25
        $this->waiting[] = $task;
26
27
        return $this;
28
    }
29
30
    /**
31
     * @inheritdoc
32
     *
33
     * @return bool
34
     */
35
    public function tick()
36
    {
37
        foreach ($this->waiting as $task) {
38
            $handler = $task->getHandler();
39
40
            $object = new $handler();
41
42
            if ($object instanceof Handler) {
43
                $object->handle($task);
44
            }
45
        }
46
47
        return false;
48
    }
49
}
50