Failed Conditions
Pull Request — develop (#3131)
by Michael
60:38
created

DriverRequired::new()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Exception;
6
7
use Doctrine\DBAL\DBALException;
8
use function sprintf;
9
10
final class DriverRequired extends DBALException
11
{
12
    /**
13
     * @param string|null $url The URL that was provided in the connection parameters (if any).
14
     */
15
    public static function new(?string $url = null) : self
16
    {
17
        if ($url !== null) {
18
            return new self(
19
                sprintf(
20
                    "The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme "
21
                        . 'is given to DriverManager::getConnection(). Given URL: %s',
22
                    $url
23
                )
24
            );
25
        }
26
27
        return new self(
28
            "The options 'driver' or 'driverClass' are mandatory if no PDO "
29
                . 'instance is given to DriverManager::getConnection().'
30
        );
31
    }
32
}
33