Skip to content

Commit

Permalink
Merge pull request #5 from Naouak/uri-generic
Browse files Browse the repository at this point in the history
The uri param should be a generic PSR UriInterface
  • Loading branch information
byjg authored Mar 5, 2018
2 parents 424df69 + a32c1a9 commit 092af17
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/Database/DatabaseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ByJG\DbMigration\Database;

use ByJG\Util\Uri;
use Psr\Http\Message\UriInterface;

interface DatabaseInterface
{
public static function prepareEnvironment(Uri $dbDriver);
public static function prepareEnvironment(UriInterface $dbDriver);

public function createDatabase();

Expand Down
3 changes: 2 additions & 1 deletion src/Database/DblibDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use ByJG\AnyDataset\Factory;
use ByJG\Util\Uri;
use Psr\Http\Message\UriInterface;

class DblibDatabase extends AbstractDatabase
{

public static function prepareEnvironment(Uri $uri)
public static function prepareEnvironment(UriInterface $uri)
{
$database = preg_replace('~^/~', '', $uri->getPath());

Expand Down
3 changes: 2 additions & 1 deletion src/Database/MysqlDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use ByJG\AnyDataset\Factory;
use ByJG\Util\Uri;
use Psr\Http\Message\UriInterface;

class MySqlDatabase extends AbstractDatabase
{

public static function prepareEnvironment(Uri $uri)
public static function prepareEnvironment(UriInterface $uri)
{
$database = preg_replace('~^/~', '', $uri->getPath());

Expand Down
5 changes: 3 additions & 2 deletions src/Database/PgsqlDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

use ByJG\AnyDataset\Factory;
use ByJG\Util\Uri;
use Psr\Http\Message\UriInterface;

class PgsqlDatabase extends AbstractDatabase
{

public static function prepareEnvironment(Uri $uri)
public static function prepareEnvironment(UriInterface $uri)
{
$database = preg_replace('~^/~', '', $uri->getPath());
$dbDriver = self::getDbDriverWithoutDatabase($uri);
self::createDatabaseIfNotExists($dbDriver, $database);
}

protected static function getDbDriverWithoutDatabase(Uri $uri)
protected static function getDbDriverWithoutDatabase(UriInterface $uri)
{
$customUri = new Uri($uri->__toString());
return Factory::getDbRelationalInstance($customUri->withPath('/')->__toString());
Expand Down
4 changes: 2 additions & 2 deletions src/Database/SqliteDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace ByJG\DbMigration\Database;

use ByJG\Util\Uri;
use Psr\Http\Message\UriInterface;

class SqliteDatabase extends AbstractDatabase
{

public static function prepareEnvironment(Uri $uri)
public static function prepareEnvironment(UriInterface $uri)
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
use ByJG\DbMigration\Database\DatabaseInterface;
use ByJG\DbMigration\Exception\DatabaseIsIncompleteException;
use ByJG\DbMigration\Exception\InvalidMigrationFile;
use ByJG\Util\Uri;
use Psr\Http\Message\UriInterface;

class Migration
{
/**
* @var Uri
* @var UriInterface
*/
protected $uri;

Expand All @@ -39,11 +39,11 @@ class Migration
/**
* Migration constructor.
*
* @param Uri $uri
* @param UriInterface $uri
* @param string $folder
* @throws \ByJG\DbMigration\Exception\InvalidMigrationFile
*/
public function __construct(Uri $uri, $folder)
public function __construct(UriInterface $uri, $folder)
{
$this->uri = $uri;
$this->folder = $folder;
Expand Down

0 comments on commit 092af17

Please sign in to comment.