StopwatchAwareTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 10
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A setStopwatch() 0 6 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Helpers/StopwatchAwareTrait.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Helpers;
10
11
use Symfony\Component\Stopwatch\Stopwatch;
12
use Symfony\Contracts\Service\Attribute\Required;
13
14
/**
15
 * Class StopwatchAwareTrait
16
 *
17
 * NOTE: Do not use this in your services, just inject `Stopwatch` to service
18
 *       where you need it. This trait is just for quick debug purposes and
19
 *       nothing else.
20
 *
21
 * @package App\Helpers
22
 * @author TLe, Tarmo Leppänen <[email protected]>
23
 */
24
trait StopwatchAwareTrait
25
{
26
    protected ?Stopwatch $stopwatch = null;
27
28 1
    #[Required]
29
    public function setStopwatch(Stopwatch $stopwatch): self
30
    {
31 1
        $this->stopwatch = $stopwatch;
32
33 1
        return $this;
34
    }
35
}
36