classPlatformFactory
final class PlatformFactory
@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.
\SqlFixture\Provider\PlatformFactory::resolveVersion('mysql', 'mysql-8.0.44')->number // => '8.0.44'\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,
): SchemaParserInterfaceCreate a schema parser for the given driver and release.
Parameters
$driver | string | |
$version | string|null | Version tag such as `mysql-8.4.7`, or null for the default of the driver |
Returns
Throws
UnsupportedDriverException If the driver is not supportedUnsupportedVersionException If the version tag is not a supported release of the driverTest cases 5
Called from 4
- static-call SqlFixture\Provider\DatabaseFixtureProvider::__construct() packages/sql-fixture/src/Provider/DatabaseFixtureProvider.php:66
- static-call SqlFixture\Provider\FileFixtureProvider::__construct() packages/sql-fixture/src/Provider/FileFixtureProvider.php:54
- static-call SqlFixture\Provider\FixtureProvider::__construct() packages/sql-fixture/src/Provider/FixtureProvider.php:73
- static-call SqlFixture\Provider\SqlSchemaProvider::getSchema() packages/sql-fixture/src/Provider/SqlSchemaProvider.php:39
Calls 8
- static-call PlatformFactory::resolveVersion() line 62
- class-const PlatformFactory::DRIVER_MYSQL() line 65
- new MySqlSchemaParser line 65
- class-const PlatformFactory::DRIVER_SQLITE() line 66
- new SqliteSchemaParser line 66
- class-const PlatformFactory::DRIVER_PGSQL() line 67
- new PostgreSqlSchemaParser line 67
- new UnsupportedDriverException line 68
public static function createTypeMapper(string $driver): TypeMapperInterfaceCreate a type mapper for the given driver.
Parameters
$driver | string |
Returns
Throws
UnsupportedDriverException If the driver is not supportedTest cases 3
Called from 3
- static-call SqlFixture\Provider\DatabaseFixtureProvider::__construct() packages/sql-fixture/src/Provider/DatabaseFixtureProvider.php:65
- static-call SqlFixture\Provider\FileFixtureProvider::__construct() packages/sql-fixture/src/Provider/FileFixtureProvider.php:53
- static-call SqlFixture\Provider\FixtureProvider::__construct() packages/sql-fixture/src/Provider/FixtureProvider.php:72
Calls 7
- class-const PlatformFactory::DRIVER_MYSQL() line 80
- new MySqlTypeMapper line 80
- class-const PlatformFactory::DRIVER_SQLITE() line 81
- new SqliteTypeMapper line 81
- class-const PlatformFactory::DRIVER_PGSQL() line 82
- new PostgreSqlTypeMapper line 82
- new UnsupportedDriverException line 83
public static function createSchemaFetcher(
string $driver,
string|null $version = null,
): SchemaFetcherInterfaceCreate a schema fetcher for the given driver and release.
Parameters
$driver | string | |
$version | string|null | Version tag such as `mysql-8.4.7`, or null for the default of the driver |
Returns
Throws
UnsupportedDriverException If the driver is not supportedUnsupportedVersionException If the version tag is not a supported release of the driverTest cases 4
Called from 1
Calls 8
- static-call PlatformFactory::resolveVersion() line 97
- class-const PlatformFactory::DRIVER_MYSQL() line 100
- new MySqlSchemaFetcher line 100
- class-const PlatformFactory::DRIVER_SQLITE() line 101
- new SqliteSchemaFetcher line 101
- class-const PlatformFactory::DRIVER_PGSQL() line 102
- new PostgreSqlSchemaFetcher line 102
- new UnsupportedDriverException line 103
public static function resolveVersion(
string $driver,
string|null $version = null,
): ServerVersionResolve the release a version tag names, the default of the driver when none is given.
Parameters
$driver | string | |
$version | string|null | Version tag such as `mysql-8.4.7`, or null for the default of the driver |
Returns
Throws
UnsupportedDriverException If the driver is not supportedUnsupportedVersionException If the version tag is not a supported release of the driverTest cases 2
Called from 5
- static-call SqlFixture\Provider\FileFixtureProvider::__construct() packages/sql-fixture/src/Provider/FileFixtureProvider.php:51
- static-call SqlFixture\Provider\FixtureProvider::__construct() packages/sql-fixture/src/Provider/FixtureProvider.php:69
- static-call SqlFixture\Provider\PlatformFactory::createSchemaParser() packages/sql-fixture/src/Provider/PlatformFactory.php:62
- static-call SqlFixture\Provider\PlatformFactory::createSchemaFetcher() packages/sql-fixture/src/Provider/PlatformFactory.php:97
- static-call SqlFixture\Provider\SqlSchemaProvider::getSchema() packages/sql-fixture/src/Provider/SqlSchemaProvider.php:33
Calls 4
- function-call
in_arrayline 117 - static-call PlatformFactory::getSupportedDrivers() line 117
- new UnsupportedDriverException line 118
- static-call ServerVersion::resolve() line 121
public static function detectDriver(PDO $pdo): stringDetect the driver name from a PDO connection.
Parameters
$pdo | PDO |
Returns
stringThrows
DriverDetectionException If the connection does not report a driver nameUnsupportedDriverException If the reported driver is not supportedTest cases 2
Called from 2
Calls 8
- method-call
PDO::getAttribute()line 132 - class-const
PDO::ATTR_DRIVER_NAME()line 132 - function-call
is_stringline 134 - new DriverDetectionException line 135
- class-const PlatformFactory::DRIVER_MYSQL() line 139
- class-const PlatformFactory::DRIVER_SQLITE() line 140
- class-const PlatformFactory::DRIVER_PGSQL() line 141
- new UnsupportedDriverException line 142
public static function detectVersion(PDO $pdo, string|null $version = null): ServerVersionDetect 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
$pdo | PDO | |
$version | string|null | Version tag such as `mysql-8.4.7`, or null to read the server version |
Returns
Throws
DriverDetectionException If the connection does not report a driver name or a server versionUnsupportedDriverException If the reported driver is not supportedUnsupportedVersionException If the version tag is not a supported release of the driverTest cases 3
Called from 1
Calls 7
- static-call PlatformFactory::detectDriver() line 161
- static-call ServerVersion::resolve() line 163
- method-call
PDO::getAttribute()line 166 - class-const
PDO::ATTR_SERVER_VERSION()line 166 - function-call
is_stringline 167 - new DriverDetectionException line 168
- static-call ServerVersion::fromServer() line 171
public static function getSupportedDrivers(): list<string>Get the list of supported drivers.
Returns
list<string>Test cases 1
Called from 2
Calls 3
- class-const PlatformFactory::DRIVER_MYSQL() line 182
- class-const PlatformFactory::DRIVER_SQLITE() line 183
- class-const PlatformFactory::DRIVER_PGSQL() line 184
public static function getSupportedVersions(string $driver): non-empty-list<string>Get the version tags of the releases supported for a driver, oldest first.
Parameters
$driver | string |
Returns
non-empty-list<string> Version tags such as `mysql-8.4.7`Throws
UnsupportedDriverException If the driver is not supportedTest cases 1
Calls 4
- function-call
in_arrayline 197 - static-call PlatformFactory::getSupportedDrivers() line 197
- new UnsupportedDriverException line 198
- static-call ServerVersion::tags() line 201
Test cases 38§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 20
PlatformFactoryTest::testCreateSchemaFetcherForMysqlcallsPlatformFactoryTest::testCreateSchemaFetcherForPgsqlcallsPlatformFactoryTest::testCreateSchemaFetcherForSqlitecallsPlatformFactoryTest::testCreateSchemaFetcherRejectsAnUnsupportedTagcallsPlatformFactoryTest::testCreateSchemaParserForMysqlcallsPlatformFactoryTest::testCreateSchemaParserForPgsqlcallsPlatformFactoryTest::testCreateSchemaParserForSqlitecallsPlatformFactoryTest::testCreateSchemaParserRejectsATagOfAnotherDrivercallsPlatformFactoryTest::testCreateTypeMapperForMysqlcallsPlatformFactoryTest::testCreateTypeMapperForPgsqlcallsPlatformFactoryTest::testCreateTypeMapperForSqlitecallsPlatformFactoryTest::testDetectDriverForSqlitecallsPlatformFactoryTest::testDetectDriverReadsTheNativeConnectioncallsPlatformFactoryTest::testDetectVersionMatchesTheLinkedSqlitecallsPlatformFactoryTest::testDetectVersionReadsTheNativeServercallsPlatformFactoryTest::testDetectVersionResolvesAnExplicitTagAgainstTheDetectedDrivercallsPlatformFactoryTest::testGetSupportedDriverscallsPlatformFactoryTest::testGetSupportedVersionsListsTheTagsOfADrivercallsPlatformFactoryTest::testResolveVersionNamesTheDefaultOfTheDrivercallsPlatformFactoryTest::testResolveVersionRejectsAnUnsupportedTagcalls
Other tests reaching this symbol 18
CreateTableTarget::__invokecallsPostgreSqlEndToEndTest::fixtureReproducibleWithSeedcallsPostgreSqlEndToEndTest::fixtureWithArrayTypescallsPostgreSqlEndToEndTest::fixtureWithCommonTypescallsPostgreSqlEndToEndTest::fixtureWithGeneratedColumncallsPostgreSqlEndToEndTest::fixtureWithNumericPrecisioncallsPostgreSqlEndToEndTest::fixtureWithOverridescallsPostgreSqlEndToEndTest::fixtureWithPgSpecificTypescallsPostgreSqlEndToEndTest::fixtureWithSerialTypescallsPostgreSqlEndToEndTest::fixtureWithTimestampVariantscallsSqliteIntegrationTest::databaseFixtureProviderWithSqlitecallsSqliteIntegrationTest::fixtureProviderDialectOverridecallsSqliteIntegrationTest::fixtureProviderWithSqliteDialectcallsDatabaseFixtureProviderTestcallsFileFixtureProviderTest::testGetDialectAndGetVersionNameTheSelectedReleasecallsFixtureProviderTest::testFixtureReadsOneStatementForAnotherReleasecallsFixtureProviderTest::testGetVersionDefaultsToTheNewestShippedMysqlcallsSqlSchemaProviderTestcalls
Relations§
Static calls 13
- static-call SqlFixture\Provider\DatabaseFixtureProvider::__construct() packages/sql-fixture/src/Provider/DatabaseFixtureProvider.php:62
- static-call SqlFixture\Provider\DatabaseFixtureProvider::__construct() packages/sql-fixture/src/Provider/DatabaseFixtureProvider.php:63
- static-call SqlFixture\Provider\DatabaseFixtureProvider::__construct() packages/sql-fixture/src/Provider/DatabaseFixtureProvider.php:65
- static-call SqlFixture\Provider\DatabaseFixtureProvider::__construct() packages/sql-fixture/src/Provider/DatabaseFixtureProvider.php:66
- static-call SqlFixture\Provider\DatabaseFixtureProvider::__construct() packages/sql-fixture/src/Provider/DatabaseFixtureProvider.php:68
- static-call SqlFixture\Provider\FileFixtureProvider::__construct() packages/sql-fixture/src/Provider/FileFixtureProvider.php:51
- static-call SqlFixture\Provider\FileFixtureProvider::__construct() packages/sql-fixture/src/Provider/FileFixtureProvider.php:53
- static-call SqlFixture\Provider\FileFixtureProvider::__construct() packages/sql-fixture/src/Provider/FileFixtureProvider.php:54
- static-call SqlFixture\Provider\FixtureProvider::__construct() packages/sql-fixture/src/Provider/FixtureProvider.php:69
- static-call SqlFixture\Provider\FixtureProvider::__construct() packages/sql-fixture/src/Provider/FixtureProvider.php:72
- static-call SqlFixture\Provider\FixtureProvider::__construct() packages/sql-fixture/src/Provider/FixtureProvider.php:73
- static-call SqlFixture\Provider\SqlSchemaProvider::getSchema() packages/sql-fixture/src/Provider/SqlSchemaProvider.php:33
- static-call SqlFixture\Provider\SqlSchemaProvider::getSchema() packages/sql-fixture/src/Provider/SqlSchemaProvider.php:39