Skip to content

Commit

Permalink
fix: Use schema abstract, drop SchemaContract (#12)
Browse files Browse the repository at this point in the history
* using schema abstract

* Remove SchemaContract

Co-authored-by: innoflash <[email protected]>
  • Loading branch information
owenconti and innoflash authored May 3, 2020
1 parent be58a89 commit a7cec22
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/Commands/ListColumnsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace OhSeeSoftware\LaravelSchemaList\Commands;

use Illuminate\Console\Command;
use OhSeeSoftware\LaravelSchemaList\Schemas\SchemaContract;
use OhSeeSoftware\LaravelSchemaList\Schemas\Schema;

class ListColumnsCommand extends Command
{
Expand All @@ -13,7 +13,7 @@ class ListColumnsCommand extends Command
/** @var string */
protected $description = 'Lists the columns in the given table.';

public function handle(SchemaContract $schema)
public function handle(Schema $schema)
{
$headers = ['Field', 'Type', 'Nullable', 'Key', 'Default Value', 'Extra'];
$rows = $schema->getColumns($this->argument('table'));
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/ListTablesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use OhSeeSoftware\LaravelSchemaList\Schemas\SchemaContract;
use OhSeeSoftware\LaravelSchemaList\Schemas\Schema;

class ListTablesCommand extends Command
{
Expand All @@ -14,7 +14,7 @@ class ListTablesCommand extends Command
/** @var string */
protected $description = 'Lists the tables in the default database.';

public function handle(SchemaContract $schema)
public function handle(Schema $schema)
{
$headers = ['Tables', 'Columns', 'Rows'];
$rows = $schema->getTables();
Expand Down
9 changes: 4 additions & 5 deletions src/LaravelSchemaListServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace OhSeeSoftware\LaravelSchemaList;

use Exception;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\MySqlConnection;
use Illuminate\Database\PostgresConnection;
Expand All @@ -11,7 +10,7 @@
use OhSeeSoftware\LaravelSchemaList\Commands\ListTablesCommand;
use OhSeeSoftware\LaravelSchemaList\Schemas\MySQLSchema;
use OhSeeSoftware\LaravelSchemaList\Schemas\PostgresSchema;
use OhSeeSoftware\LaravelSchemaList\Schemas\SchemaContract;
use OhSeeSoftware\LaravelSchemaList\Schemas\Schema;
use OhSeeSoftware\LaravelSchemaList\Schemas\UnsupportedSchema;

class LaravelSchemaListServiceProvider extends ServiceProvider
Expand All @@ -29,14 +28,14 @@ public function boot()
if ($this->app->runningInConsole()) {
$this->commands([
ListTablesCommand::class,
ListColumnsCommand::class
ListColumnsCommand::class,
]);

$this->app->bind(SchemaContract::class, function () {
$this->app->bind(Schema::class, function () {
$connection = resolve(ConnectionInterface::class);
$connectionClass = get_class($connection);
$schema = $this->connections[$connectionClass] ?? UnsupportedSchema::class;

return new $schema($connection);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Schemas/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Database\ConnectionInterface;
use LogicException;

abstract class Schema implements SchemaContract
abstract class Schema
{
/** @var \Illuminate\Database\ConnectionInterface */
protected $connection;
Expand Down
10 changes: 0 additions & 10 deletions src/Schemas/SchemaContract.php

This file was deleted.

0 comments on commit a7cec22

Please sign in to comment.