Skip to content

Commit 6794c77

Browse files
committed
Apply final styles
1 parent 6102532 commit 6794c77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3283
-3434
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
->exclude('build')
1111
->append([__FILE__]);
1212

13-
// Remove overrides for incremental changes
14-
$overrides = [
15-
'array_indentation' => false,
16-
'braces' => false,
17-
'indentation_type' => false,
18-
];
13+
$overrides = [];
1914

2015
$options = [
2116
'finder' => $finder,

examples/Schemas.php

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -14,62 +14,62 @@
1414

1515
class Schemas extends \Tatter\Schemas\Config\Schemas
1616
{
17-
// Whether to continue instead of throwing exceptions
18-
public $silent = true;
19-
20-
// Which tasks to automate when a schema is not available from the service
21-
public $automate = [
22-
'draft' => true,
23-
'archive' => true,
24-
'read' => true,
25-
];
26-
27-
//--------------------------------------------------------------------
28-
// Drafting
29-
//--------------------------------------------------------------------
30-
31-
// Default handlers used to create a schema (order sensitive)
32-
// (Probably shouldn't change this unless you really know what you're doing)
33-
public $draftHandlers = [
34-
'Tatter\Schemas\Drafter\Handlers\DatabaseHandler',
35-
'Tatter\Schemas\Drafter\Handlers\ModelHandler',
36-
'Tatter\Schemas\Drafter\Handlers\DirectoryHandler',
37-
];
38-
39-
// Tables to ignore when creating the schema
40-
public $ignoredTables = ['migrations'];
41-
42-
// Namespaces to ignore (mostly for ModelHandler)
43-
public $ignoredNamespaces = [
44-
'Tests\Support',
45-
];
46-
47-
// Path the directoryHandler should scan for schema files
48-
public $schemasDirectory = APPPATH . 'Schemas';
49-
50-
//--------------------------------------------------------------------
51-
// Archiving
52-
//--------------------------------------------------------------------
53-
54-
// Default handlers to archive copies of the schema
55-
public $archiveHandlers = [
56-
'Tatter\Schemas\Archiver\Handlers\CacheHandler',
57-
];
58-
59-
// Default time-to-live for a stored schema (e.g. Cache) in seconds
60-
public $ttl = 14400; // 4 hours
61-
62-
//--------------------------------------------------------------------
63-
// Reading
64-
//--------------------------------------------------------------------
65-
66-
// Default handler used to return and read a schema
67-
public $readHandler = 'Tatter\Schemas\Reader\Handlers\CacheHandler';
68-
69-
//--------------------------------------------------------------------
70-
// Publishing
71-
//--------------------------------------------------------------------
72-
73-
// Precaution to prevent accidental wiping of databases or files
74-
public $safeMode = true;
17+
// Whether to continue instead of throwing exceptions
18+
public $silent = true;
19+
20+
// Which tasks to automate when a schema is not available from the service
21+
public $automate = [
22+
'draft' => true,
23+
'archive' => true,
24+
'read' => true,
25+
];
26+
27+
//--------------------------------------------------------------------
28+
// Drafting
29+
//--------------------------------------------------------------------
30+
31+
// Default handlers used to create a schema (order sensitive)
32+
// (Probably shouldn't change this unless you really know what you're doing)
33+
public $draftHandlers = [
34+
'Tatter\Schemas\Drafter\Handlers\DatabaseHandler',
35+
'Tatter\Schemas\Drafter\Handlers\ModelHandler',
36+
'Tatter\Schemas\Drafter\Handlers\DirectoryHandler',
37+
];
38+
39+
// Tables to ignore when creating the schema
40+
public $ignoredTables = ['migrations'];
41+
42+
// Namespaces to ignore (mostly for ModelHandler)
43+
public $ignoredNamespaces = [
44+
'Tests\Support',
45+
];
46+
47+
// Path the directoryHandler should scan for schema files
48+
public $schemasDirectory = APPPATH . 'Schemas';
49+
50+
//--------------------------------------------------------------------
51+
// Archiving
52+
//--------------------------------------------------------------------
53+
54+
// Default handlers to archive copies of the schema
55+
public $archiveHandlers = [
56+
'Tatter\Schemas\Archiver\Handlers\CacheHandler',
57+
];
58+
59+
// Default time-to-live for a stored schema (e.g. Cache) in seconds
60+
public $ttl = 14400; // 4 hours
61+
62+
//--------------------------------------------------------------------
63+
// Reading
64+
//--------------------------------------------------------------------
65+
66+
// Default handler used to return and read a schema
67+
public $readHandler = 'Tatter\Schemas\Reader\Handlers\CacheHandler';
68+
69+
//--------------------------------------------------------------------
70+
// Publishing
71+
//--------------------------------------------------------------------
72+
73+
// Precaution to prevent accidental wiping of databases or files
74+
public $safeMode = true;
7575
}

src/Agents/SchemaAgent.php

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,32 @@
2424

2525
class SchemaAgent extends BaseAgent
2626
{
27-
/**
28-
* Attributes for Tatter\Handlers
29-
*
30-
* @var array<string, string>
31-
*/
32-
public $attributes = [
33-
'name' => 'Schema',
34-
'uid' => 'schema',
35-
'icon' => 'fas fa-project-diagram',
36-
'summary' => 'Map the database structure from the default connection',
37-
];
38-
39-
/**
40-
* Runs this Agent's status check. Usually in turn calls record().
41-
*/
42-
public function check(): void
43-
{
44-
if (! $schemas = Services::schemas())
45-
{
46-
return;
47-
}
48-
49-
$config = config('Schemas');
50-
51-
// Generate the schema
52-
$schema = $schemas->import(...$config->defaultHandlers)->get();
53-
54-
$this->record('defaultSchema', 'object', $schema);
55-
}
27+
/**
28+
* Attributes for Tatter\Handlers
29+
*
30+
* @var array<string, string>
31+
*/
32+
public $attributes = [
33+
'name' => 'Schema',
34+
'uid' => 'schema',
35+
'icon' => 'fas fa-project-diagram',
36+
'summary' => 'Map the database structure from the default connection',
37+
];
38+
39+
/**
40+
* Runs this Agent's status check. Usually in turn calls record().
41+
*/
42+
public function check(): void
43+
{
44+
if (! $schemas = Services::schemas()) {
45+
return;
46+
}
47+
48+
$config = config('Schemas');
49+
50+
// Generate the schema
51+
$schema = $schemas->import(...$config->defaultHandlers)->get();
52+
53+
$this->record('defaultSchema', 'object', $schema);
54+
}
5655
}

src/Archiver/ArchiverInterface.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
interface ArchiverInterface
88
{
9-
/**
10-
* Store a copy of the schema to its destination
11-
*
12-
* @return bool Success or failure
13-
*/
14-
public function archive(Schema $schema): bool;
9+
/**
10+
* Store a copy of the schema to its destination
11+
*
12+
* @return bool Success or failure
13+
*/
14+
public function archive(Schema $schema): bool;
1515
}

src/Archiver/BaseArchiver.php

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,31 @@
1313
*/
1414
abstract class BaseArchiver extends BaseHandler
1515
{
16-
/**
17-
* Validate or create a file and write to it.
18-
*
19-
* @param string $path The path to the file
20-
*
21-
* @throws FileNotFoundException
22-
*
23-
* @return bool Success or failure
24-
*/
25-
protected function putContents($path, string $data): bool
26-
{
27-
$file = new File($path);
28-
29-
if (! $file->isWritable())
30-
{
31-
if ($this->config->silent)
32-
{
33-
$this->errors[] = lang('Files.fileNotFound', [$path]);
34-
35-
return false;
36-
}
37-
38-
throw FileNotFoundException::forFileNotFound($path);
39-
40-
}
41-
42-
$file = $file->openFile('w');
43-
44-
return (bool) $file->fwrite($data);
45-
}
16+
/**
17+
* Validate or create a file and write to it.
18+
*
19+
* @param string $path The path to the file
20+
*
21+
* @throws FileNotFoundException
22+
*
23+
* @return bool Success or failure
24+
*/
25+
protected function putContents($path, string $data): bool
26+
{
27+
$file = new File($path);
28+
29+
if (! $file->isWritable()) {
30+
if ($this->config->silent) {
31+
$this->errors[] = lang('Files.fileNotFound', [$path]);
32+
33+
return false;
34+
}
35+
36+
throw FileNotFoundException::forFileNotFound($path);
37+
}
38+
39+
$file = $file->openFile('w');
40+
41+
return (bool) $file->fwrite($data);
42+
}
4643
}

src/Archiver/Handlers/CacheHandler.php

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,39 @@
1212

1313
class CacheHandler extends BaseArchiver implements ArchiverInterface
1414
{
15-
use CacheHandlerTrait;
16-
17-
/**
18-
* Save the config and set up the cache
19-
*
20-
* @param SchemasConfig $config The library config
21-
* @param CacheInterface $cache The cache handler to use, null to load a new default
22-
*/
23-
public function __construct(?SchemasConfig $config = null, ?CacheInterface $cache = null)
24-
{
25-
parent::__construct($config);
26-
27-
$this->cacheInit($cache);
28-
}
29-
30-
/**
31-
* Store the scaffold and each individual table to cache
32-
*
33-
* @return bool Success or failure
34-
*/
35-
public function archive(Schema $schema): bool
36-
{
37-
// Grab the tables to store separately
38-
$tables = $schema->tables;
39-
$schema->tables = new Mergeable();
40-
41-
// Save each individual table
42-
foreach ($tables as $table)
43-
{
44-
$schema->tables->{$table->name} = true;
45-
$this->cache->save($this->cacheKey . '-' . $table->name, $table, $this->config->ttl);
46-
}
47-
48-
// Save the scaffold version of the schema
49-
return $this->cache->save($this->cacheKey, $schema, $this->config->ttl);
50-
}
15+
use CacheHandlerTrait;
16+
17+
/**
18+
* Save the config and set up the cache
19+
*
20+
* @param SchemasConfig $config The library config
21+
* @param CacheInterface $cache The cache handler to use, null to load a new default
22+
*/
23+
public function __construct(?SchemasConfig $config = null, ?CacheInterface $cache = null)
24+
{
25+
parent::__construct($config);
26+
27+
$this->cacheInit($cache);
28+
}
29+
30+
/**
31+
* Store the scaffold and each individual table to cache
32+
*
33+
* @return bool Success or failure
34+
*/
35+
public function archive(Schema $schema): bool
36+
{
37+
// Grab the tables to store separately
38+
$tables = $schema->tables;
39+
$schema->tables = new Mergeable();
40+
41+
// Save each individual table
42+
foreach ($tables as $table) {
43+
$schema->tables->{$table->name} = true;
44+
$this->cache->save($this->cacheKey . '-' . $table->name, $table, $this->config->ttl);
45+
}
46+
47+
// Save the scaffold version of the schema
48+
return $this->cache->save($this->cacheKey, $schema, $this->config->ttl);
49+
}
5150
}

src/Archiver/Handlers/CliHandler.php

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

99
class CliHandler extends BaseArchiver implements ArchiverInterface
1010
{
11-
/**
12-
* Write out the schema to standard output via Kint
13-
*
14-
* @return bool true
15-
*/
16-
public function archive(Schema $schema): bool
17-
{
18-
// @phpstan-ignore-next-line
19-
+d($schema); // plus disables Kint's depth limit
11+
/**
12+
* Write out the schema to standard output via Kint
13+
*
14+
* @return bool true
15+
*/
16+
public function archive(Schema $schema): bool
17+
{
18+
// @phpstan-ignore-next-line
19+
+d($schema); // plus disables Kint's depth limit
2020

21-
return true;
22-
}
21+
return true;
22+
}
2323
}

0 commit comments

Comments
 (0)