Processor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 15
dl 0
loc 25
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 19 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