Dispatcher::dispatch()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WSW\BrowserAutomation\Scenario\Dispatcher;
6
7
use Facebook\WebDriver\WebDriver;
8
use WSW\BrowserAutomation\Scenario\Scenario;
9
10
/**
11
 * Class Dispatcher
12
 *
13
 * @package WSW\BrowserAutomation\Scenario\Dispatcher
14
 */
15
class Dispatcher implements DispatcherInterface
16
{
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 9
    public function dispatch(Scenario $scenario, WebDriver $driver): array
22
    {
23 9
        $start  = microtime(true);
24
25 9
        call_user_func($scenario->getCallback(), $scenario->pipeline());
26 9
        $tasks = $scenario->pipeline()->process($driver);
27
28
        return [
29 9
            'name'  => $scenario->getName(),
30 9
            'tasks' => $tasks,
31 9
            'duration' => round(microtime(true) - $start, 4)
32
        ];
33
    }
34
}
35