HealthzService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 6 1
A __construct() 0 3 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Utils/HealthzService.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Utils;
10
11
use App\Entity\Healthz;
12
use App\Repository\HealthzRepository;
13
use Throwable;
14
15
/**
16
 * Class HealthzService
17
 *
18
 * @package App\Utils
19
 * @author TLe, Tarmo Leppänen <[email protected]>
20
 */
21
class HealthzService
22
{
23 3
    public function __construct(
24
        private readonly HealthzRepository $repository,
25
    ) {
26 3
    }
27
28
    /**
29
     * Method to check that "all" is ok within our application. This will try
30
     * to do following:
31
     *  1) Remove data from database
32
     *  2) Create data to database
33
     *  3) Read data from database
34
     *
35
     * These steps should make sure that at least application database is
36
     * working as expected.
37
     *
38
     * @throws Throwable
39
     */
40 3
    public function check(): ?Healthz
41
    {
42 3
        $this->repository->cleanup();
43 3
        $this->repository->create();
44
45 3
        return $this->repository->read();
46
    }
47
}
48