Skip to content

Commit 90df652

Browse files
authored
Merge pull request #35 from tattersoftware/styles
Apply Code Styles
2 parents 5a30c93 + 6794c77 commit 90df652

Some content is hidden

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

60 files changed

+3527
-3660
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,11 @@
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,
2217
'cacheFile' => 'build/.php-cs-fixer.cache',
2318
];
2419

2520
return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects();
26-
27-
/* Reenable For libraries after incremental changes are applied
28-
return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary(
29-
'Tatter ________',
30-
'Tatter Software',
31-
'',
32-
2021
33-
);
34-
*/

examples/Schemas.php

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,75 @@
1-
<?php namespace Config;
1+
<?php
22

3-
/***
3+
namespace Config;
4+
5+
/*
46
*
57
* This file contains example values to alter default library behavior.
68
* Recommended usage:
79
* 1. Copy the file to app/Config/
810
* 2. Change any values
911
* 3. Remove any lines to fallback to defaults
1012
*
11-
***/
13+
*/
1214

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

src/Agents/SchemaAgent.php

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Tatter\Schemas\Agents;
1+
<?php
2+
3+
namespace Tatter\Schemas\Agents;
24

35
/**
46
* Tatter\Agents
@@ -22,35 +24,32 @@
2224

2325
class SchemaAgent extends BaseAgent
2426
{
25-
/**
26-
* Attributes for Tatter\Handlers
27-
*
28-
* @var array<string, string>
29-
*/
30-
public $attributes = [
31-
'name' => 'Schema',
32-
'uid' => 'schema',
33-
'icon' => 'fas fa-project-diagram',
34-
'summary' => 'Map the database structure from the default connection',
35-
];
36-
37-
/**
38-
* Runs this Agent's status check. Usually in turn calls record().
39-
*
40-
* @return void
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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<?php namespace Tatter\Schemas\Archiver;
1+
<?php
2+
3+
namespace Tatter\Schemas\Archiver;
24

35
use Tatter\Schemas\Structures\Schema;
46

57
interface ArchiverInterface
68
{
7-
/**
8-
* Store a copy of the schema to its destination
9-
*
10-
* @param Schema $schema
11-
*
12-
* @return boolean 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: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Tatter\Schemas\Archiver;
1+
<?php
2+
3+
namespace Tatter\Schemas\Archiver;
24

35
use CodeIgniter\Files\Exceptions\FileNotFoundException;
46
use CodeIgniter\Files\File;
@@ -11,34 +13,31 @@
1113
*/
1214
abstract class BaseArchiver extends BaseHandler
1315
{
14-
/**
15-
* Validate or create a file and write to it.
16-
*
17-
* @param string $path The path to the file
18-
*
19-
* @return boolean Success or failure
20-
*
21-
* @throws FileNotFoundException
22-
*/
23-
protected function putContents($path, string $data): bool
24-
{
25-
$file = new File($path);
26-
27-
if (! $file->isWritable())
28-
{
29-
if ($this->config->silent)
30-
{
31-
$this->errors[] = lang('Files.fileNotFound', [$path]);
32-
return false;
33-
}
34-
else
35-
{
36-
throw FileNotFoundException::forFileNotFound($path);
37-
}
38-
}
39-
40-
$file = $file->openFile('w');
41-
42-
return (bool) $file->fwrite($data);
43-
}
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+
}
4443
}

0 commit comments

Comments
 (0)