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

DriverRequired   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 20
c 0
b 0
f 0
rs 10

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
    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