Failed Conditions
Pull Request — develop (#3131)
by Michael
12:37
created

DriverRequired   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A new() 0 15 2
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 80
    public static function new(?string $url = null) : self
16
    {
17 80
        if ($url !== null) {
18 64
            return new self(
19 64
                sprintf(
20
                    "The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme "
21 64
                        . "is given to DriverManager::getConnection(). Given URL: %s",
22 64
                    $url
23
                )
24
            );
25
        }
26
27 16
        return new self(
28
            "The options 'driver' or 'driverClass' are mandatory if no PDO "
29 16
                . "instance is given to DriverManager::getConnection()."
30
        );
31
    }
32
}
33