Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The uri param should be a generic PSR UriInterface #5

Merged
merged 2 commits into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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