Completed
Push — develop ( 40c4f3...ed7ad1 )
by Sergei
62:39
created

DriverMock::_constructPdoDsn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace Doctrine\Tests\Mocks;
4
5
use Doctrine\DBAL\Connection;
6
use Doctrine\DBAL\DBALException;
7
use Doctrine\DBAL\Driver;
8
use Doctrine\DBAL\Platforms\AbstractPlatform;
9
use Doctrine\DBAL\Schema\AbstractSchemaManager;
10
use Throwable;
11
12
class DriverMock implements Driver
13
{
14
    /** @var DatabasePlatformMock */
15
    private $platformMock;
16
17
    /** @var AbstractSchemaManager */
18
    private $schemaManagerMock;
19
20
    /**
21
     * {@inheritDoc}
22
     */
23
    public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
24
    {
25
        throw new DBALException('Not implemented');
26
    }
27
28
    public function getDatabasePlatform()
29
    {
30
        if (! $this->platformMock) {
31
            $this->platformMock = new DatabasePlatformMock();
32
        }
33
        return $this->platformMock;
34
    }
35
36
    public function getSchemaManager(Connection $conn)
37
    {
38
        if ($this->schemaManagerMock === null) {
39
            return new SchemaManagerMock($conn);
40
        }
41
42
        return $this->schemaManagerMock;
43
    }
44
45
    public function setDatabasePlatform(AbstractPlatform $platform)
46
    {
47
        $this->platformMock = $platform;
0 ignored issues
show
Documentation Bug introduced by
$platform is of type Doctrine\DBAL\Platforms\AbstractPlatform, but the property $platformMock was declared to be of type Doctrine\Tests\Mocks\DatabasePlatformMock. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
48
    }
49
50
    public function setSchemaManager(AbstractSchemaManager $sm)
51
    {
52
        $this->schemaManagerMock = $sm;
53
    }
54
55
    public function getName()
56
    {
57
        return 'mock';
58
    }
59
60
    public function getDatabase(Connection $conn)
61
    {
62
        return;
63
    }
64
65
    public function convertExceptionCode(Throwable $exception)
0 ignored issues
show
Unused Code introduced by
The parameter $exception is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

65
    public function convertExceptionCode(/** @scrutinizer ignore-unused */ Throwable $exception)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
66
    {
67
        return 0;
68
    }
69
}
70