Passed
Push — master ( 8982d0...8ad996 )
by Nils
02:53 queued 10s
created

DatabaseConnected::getIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Leankoala\HealthFoundation\Check\Frameworks\Symfony;
4
5
use Doctrine\Bundle\DoctrineBundle\Registry;
0 ignored issues
show
Bug introduced by
The type Doctrine\Bundle\DoctrineBundle\Registry was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Doctrine\DBAL\Connection;
0 ignored issues
show
Bug introduced by
The type Doctrine\DBAL\Connection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Leankoala\HealthFoundation\Check\Check;
8
use Leankoala\HealthFoundation\Check\Result;
9
10
/**
11
 * Class DatabaseConnected
12
 *
13
 * @package Leankoala\HealthFoundation\Check\Frameworks\Symfony
14
 *
15
 * @author Nils Langner <[email protected]>
16
 * created 2021-03-02
17
 */
18
class DatabaseConnected implements Check
19
{
20
    const IDENTIFIER = 'base:frameworks:symfony:databaseConnected';
21
22
    /**
23
     * @var Registry
24
     */
25
    private $doctrine;
26
27
    public function __construct(Registry $doctrine)
28
    {
29
        $this->doctrine = $doctrine;
30
    }
31
32
    public function run()
33
    {
34
        /** @var Connection $connection */
35
        $connection = $this->doctrine->getConnection();
36
37
        if ($connection->isConnected()) {
38
            $result = new Result(Result::STATUS_PASS, 'Doctrine is connected to the database.');
39
        } else {
40
            $result = new Result(Result::STATUS_FAIL, 'Doctrine is not connected to the database.');
41
        }
42
43
        return $result;
44
    }
45
46
    public function getIdentifier()
47
    {
48
        return self::IDENTIFIER;
49
    }
50
}
51