Stopwatch::start()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
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 MovingImage\Bundle\VMProApiBundle\Service;
6
7
use MovingImage\Client\VMPro\Interfaces\StopwatchInterface;
8
use Symfony\Component\Stopwatch\Stopwatch as SymfonyStopwatch;
9
use Symfony\Component\Stopwatch\StopwatchEvent;
10
11
/**
12
 * Adapter for Symfony Stopwatch, implementing the StopwatchInterface.
13
 */
14
class Stopwatch implements StopwatchInterface
15
{
16
    /**
17
     * @var SymfonyStopwatch
18
     */
19
    private $delegate;
20
21
    /**
22
     * @var StopwatchEvent[]
23
     */
24
    private $events = [];
25
26
    public function __construct(SymfonyStopwatch $delegate)
27 4
    {
28
        $this->delegate = $delegate;
29 4
    }
30 4
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function start(string $name, ?string $category = null): void
35 4
    {
36
        $this->delegate->start($name, $category);
37 4
    }
38 4
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function stop(string $name): void
43 4
    {
44
        $this->events[$name] = $this->delegate->stop($name);
45 4
    }
46 4
47
    /**
48
     * @return StopwatchEvent[]
49
     */
50
    public function getEvents(): array
51 2
    {
52
        return $this->events;
53 2
    }
54
}
55