Skip to content

Commit 7cdad7d

Browse files
committed
refactor: Rename
1 parent 3465394 commit 7cdad7d

File tree

8 files changed

+26
-41
lines changed

8 files changed

+26
-41
lines changed

src/App.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88

99
class App extends Application
1010
{
11-
/**
12-
* @var Container
13-
*/
14-
private $container;
15-
1611
public function __construct(Container $container)
1712
{
1813
$version = 'dev-master';
@@ -23,20 +18,10 @@ public function __construct(Container $container)
2318

2419
parent::__construct('Schemarkdown', $version);
2520

26-
$this->container = $container;
27-
2821
$this->addCommands([
2922
new GenerateCommand($container),
3023
]);
3124

3225
$this->setDefaultCommand('generate');
3326
}
34-
35-
/**
36-
* @return Container
37-
*/
38-
public function getContainer(): Container
39-
{
40-
return $this->container;
41-
}
4227
}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
use Illuminate\Database\DatabaseManager;
88
use Illuminate\Support\Facades\View;
99
use Illuminate\Support\Str;
10+
use MilesChou\Schemarkdown\Models\Schema;
11+
use MilesChou\Schemarkdown\Models\Table;
1012
use Psr\Log\LoggerInterface;
1113

12-
class CodeBuilder
14+
class Builder
1315
{
1416
/**
1517
* @var array
@@ -86,8 +88,8 @@ private function buildConnection($connection)
8688

8789
$this->logger->info("Build readme markdown '{$relativePath}' ...");
8890

89-
yield $relativePath => View::make('database', [
90-
'database' => new Database($schemaManager, $databaseConnection->getDatabaseName()),
91+
yield $relativePath => View::make('schema', [
92+
'schema' => new Schema($schemaManager, $databaseConnection->getDatabaseName()),
9193
])->render();
9294

9395
foreach ($schemaManager->listTableNames() as $tableName) {
@@ -96,7 +98,7 @@ private function buildConnection($connection)
9698
$this->logger->info("Build schema markdown '{$relativePath}' ...");
9799

98100
yield $relativePath => View::make('table', [
99-
'schema' => new Table(
101+
'table' => new Table(
100102
$schemaManager->listTableDetails($tableName),
101103
$databaseConnection->getDatabaseName()
102104
),

src/Commands/GenerateCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Database\DatabaseManager;
77
use Illuminate\Log\LogManager;
88
use MilesChou\Codegener\Writer;
9-
use MilesChou\Schemarkdown\CodeBuilder;
9+
use MilesChou\Schemarkdown\Builder;
1010
use MilesChou\Schemarkdown\Commands\Concerns\DatabaseConnection;
1111
use MilesChou\Schemarkdown\Commands\Concerns\Environment;
1212
use Symfony\Component\Console\Command\Command;
@@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8484
/** @var DatabaseManager $databaseManager */
8585
$databaseManager = $this->container->get('db');
8686

87-
$code = (new CodeBuilder($this->container, $databaseManager))->build();
87+
$code = (new Builder($this->container, $databaseManager))->build();
8888

8989
$logger = $this->container->make('log');
9090

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace MilesChou\Schemarkdown;
3+
namespace MilesChou\Schemarkdown\Models;
44

55
use Doctrine\DBAL\Schema\AbstractSchemaManager;
66
use Illuminate\Support\Collection;
77

8-
class Database
8+
class Schema
99
{
1010
/**
1111
* @var string

src/Table.php renamed to src/Models/Table.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<?php
22

3-
namespace MilesChou\Schemarkdown;
3+
namespace MilesChou\Schemarkdown\Models;
44

55
use Doctrine\DBAL\Schema\Column as DoctrineColumn;
66
use Doctrine\DBAL\Schema\Index as DoctrineIndex;
77
use Doctrine\DBAL\Schema\Table as DoctrineTable;
8-
use MilesChou\Schemarkdown\Models\Column;
9-
use MilesChou\Schemarkdown\Models\Index;
108

119
class Table
1210
{

src/templates/database.blade.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/templates/schema.blade.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/** @var \MilesChou\Schemarkdown\Models\Schema $schema */
3+
?>
4+
# Database `{{ $schema->database() }}`
5+
6+
## Tables
7+
8+
@foreach($schema->tables() as $table)
9+
* [{{ $table }}]({{ \Illuminate\Support\Str::snake($table) }}.md)
10+
@endforeach

src/templates/table.blade.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<?php
2-
/** @var \MilesChou\Schemarkdown\Table $schema */
2+
/** @var \MilesChou\Schemarkdown\Models\Table $table */
33
?>
4-
# Table `{{ $schema->database() }}.{{ $schema->table() }}`
4+
# Table `{{ $table->database() }}.{{ $table->table() }}`
55

6-
{{ $schema->comment() }}
6+
{{ $table->comment() }}
77

88
## Columns
99

1010
| Name | Type | Length | Precision | Not Null | Auto Increment | Default | Comment |
1111
| --- | --- | --- | --- | --- | --- | --- | --- |
12-
@foreach($schema->columns() as $column)
12+
@foreach($table->columns() as $column)
1313
| {{ $column->getName() }} | {{ $column->getType()->getName() }} | {{ $column->getLength() }} | {{ $column->getPrecision() }} | {{ $column->getNotnull() ? 'true' : 'false' }} | {{ $column->getAutoincrement() ? 'true' : 'false' }} | {{ $column->getDefault() }} | {{ $column->getComment() }} |
1414
@endforeach
1515

1616
## Indexes
1717

1818
| Name | Columns | Type |
1919
| --- | --- | --- |
20-
@foreach($schema->indexes() as $key)
20+
@foreach($table->indexes() as $key)
2121
| {{ $key->getName() }} | {{ implode(',', $key->getColumns()) }} | {{ strtoupper($key->type()) }} |
2222
@endforeach

0 commit comments

Comments
 (0)