final class PlatformFactory
Public API: explicitly declared with @visibility public.

Factory for creating platform-specific implementations.

Every platform is selected by its PDO driver name and, optionally, by the version tag of the release the statements are read for.

Resolve the release a version tag namesdoctest
\SqlFixture\Provider\PlatformFactory::resolveVersion('mysql', 'mysql-8.0.44')->number // => '8.0.44'
Read the release from a connectiondoctest
\SqlFixture\Provider\PlatformFactory::detectVersion(new \PDO('sqlite::memory:'))->tag // => 'sqlite-3.47.2'

Constants§

public const DRIVER_MYSQL = 'mysql'

PDO driver name for MySQL.

public const DRIVER_SQLITE = 'sqlite'

PDO driver name for SQLite.

public const DRIVER_PGSQL = 'pgsql'

PDO driver name for PostgreSQL.

Methods§

public static function createSchemaParser(
    string $driver,
    string|null $version = null,
): SchemaParserInterface

Create a schema parser for the given driver and release.

Parameters

$driverstring
$versionstring|nullVersion tag such as `mysql-8.4.7`, or null for the default of the driver

Throws

UnsupportedDriverException If the driver is not supported
UnsupportedVersionException If the version tag is not a supported release of the driver
Test cases 5
Called from 4
Calls 8
public static function createSchemaFetcher(
    string $driver,
    string|null $version = null,
): SchemaFetcherInterface
public static function detectDriver(PDO $pdo): string
public static function detectVersion(PDO $pdo, string|null $version = null): ServerVersion

Detect the release of the server behind a PDO connection.

The server version the connection reports is matched to the closest supported release, as ServerVersion::fromServer() describes. A version tag given explicitly is resolved against the detected driver instead.

Parameters

$pdoPDO
$versionstring|nullVersion tag such as `mysql-8.4.7`, or null to read the server version

Throws

DriverDetectionException If the connection does not report a driver name or a server version
UnsupportedDriverException If the reported driver is not supported
UnsupportedVersionException If the version tag is not a supported release of the driver
Test cases 3
Called from 1
Calls 7
public static function getSupportedVersions(string $driver): non-empty-list<string>

Get the version tags of the releases supported for a driver, oldest first.

Parameters

$driverstring

Returns

non-empty-list<string> Version tags such as `mysql-8.4.7`

Throws

UnsupportedDriverException If the driver is not supported
Test cases 1
Calls 4

Test cases 38§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 20
Other tests reaching this symbol 18

Relations§

Static calls 13
Constant reads 2