summaryrefslogtreecommitdiff
path: root/vendor/doctrine/dbal/src/Exception/DriverRequired.php
blob: e37ac68607258d15062ffd2b09e2fe12fd58f919 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

declare(strict_types=1);

namespace Doctrine\DBAL\Exception;

use function sprintf;

/** @psalm-immutable */
final class DriverRequired extends InvalidArgumentException
{
    /** @param string|null $url The URL that was provided in the connection parameters (if any). */
    public static function new(?string $url = null): self
    {
        if ($url !== null) {
            return new self(
                sprintf(
                    'The options "driver" or "driverClass" are mandatory if a connection URL without scheme '
                        . 'is given to DriverManager::getConnection(). Given URL "%s".',
                    $url,
                ),
            );
        }

        return new self(
            'The options "driver" or "driverClass" are mandatory if no PDO '
                . 'instance is given to DriverManager::getConnection().',
        );
    }
}