HealthzService::check()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 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