Processor::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 19
ccs 13
cts 13
cp 1
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WSW\BrowserAutomation\Pipeline;
6
7
use Facebook\WebDriver\WebDriver;
8
use WSW\BrowserAutomation\Task\TaskInterface;
9
10
/**
11
 * Class Processor
12
 *
13
 * @package WSW\BrowserAutomation\Pipeline
14
 */
15
class Processor implements ProcessorInterface
16
{
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 15
    public function process(TaskInterface $task, WebDriver $driver): array
22
    {
23 15
        $name   = get_class($task);
24 15
        $start  = microtime(true);
25 15
        $succes = false;
26 15
        $error  = null;
27
28
        try {
29 15
            $task->handle($driver);
30 12
            $succes = true;
31 3
        } catch (\Throwable $e) {
32 3
            $error = $e->getMessage();
33
        }
34
35
        return [
36 15
            'task' => $name,
37 15
            'success' => $succes,
38 15
            'error' => $error,
39 15
            'duration' => round(microtime(true) - $start, 4)
40
        ];
41
    }
42
}
43