Completed
Pull Request — master (#148)
by
unknown
02:18
created

DoctrineMongoDbCollection::getChecks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Liip\MonitorBundle\Check;
4
5
use Doctrine\Common\Persistence\ConnectionRegistry;
6
use ZendDiagnostics\Check\CheckCollectionInterface;
7
8
/**
9
 * @author Hugues Gobet <[email protected]>
10
 */
11
class DoctrineMongoDbCollection implements CheckCollectionInterface
12
{
13
    private $checks = array();
14
15
    public function __construct(ConnectionRegistry $manager, $connections)
16
    {
17
        if (!is_array($connections)) {
18
            $connections = array($connections);
19
        }
20
21
        foreach ($connections as $connection) {
22
            $check = new DoctrineMongoDb($manager, $connection);
0 ignored issues
show
Documentation introduced by
$manager is of type object<Doctrine\Common\P...nce\ConnectionRegistry>, but the function expects a object<Doctrine\Bundle\M...Bundle\ManagerRegistry>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
23
            $check->setLabel(sprintf('Doctrine Mongo Db "%s" connection', $connection));
24
25
            $this->checks[sprintf('doctrine_dbal_%s_connection', $connection)] = $check;
26
        }
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getChecks()
33
    {
34
        return $this->checks;
35
    }
36
}
37