Skip to content

Commit

Permalink
Update coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Jan 4, 2022
1 parent 2113ce4 commit e6f273c
Show file tree
Hide file tree
Showing 24 changed files with 1,147 additions and 1,210 deletions.
16 changes: 1 addition & 15 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,11 @@
->exclude('build')
->append([__FILE__]);

// Remove overrides for incremental changes
$overrides = [
'array_indentation' => false,
'braces' => false,
'indentation_type' => false,
];
$overrides = [];

$options = [
'finder' => $finder,
'cacheFile' => 'build/.php-cs-fixer.cache',
];

return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects();

/* Reenable For libraries after incremental changes are applied
return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary(
'Tatter ________',
'Tatter Software',
'',
2021
);
*/
38 changes: 19 additions & 19 deletions examples/Handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@

class Handlers extends \Tatter\Handlers\Config\Handlers
{
/**
* Classes to ignore across all handlers.
*
* @var array<string>
*/
public $ignoredClasses = [];
/**
* Classes to ignore across all handlers.
*
* @var array<string>
*/
public $ignoredClasses = [];

/**
* Paths to check during automatic discovery.
*
* @var array<string>
*/
public $autoDiscover = [];
/**
* Paths to check during automatic discovery.
*
* @var array<string>
*/
public $autoDiscover = [];

/**
* Number of seconds to cache discovered handlers.
* Null disables caching
*
* @var int|null
*/
public $cacheDuration = DAY;
/**
* Number of seconds to cache discovered handlers.
* Null disables caching
*
* @var int|null
*/
public $cacheDuration = DAY;
}
33 changes: 16 additions & 17 deletions src/BaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@

abstract class BaseHandler implements HandlerInterface
{
use \Tatter\Handlers\Traits\HandlerTrait;
use \Tatter\Handlers\Traits\HandlerTrait;

/**
* Attributes for Tatter\Handlers.
*
* @var array
*/
protected $attributes = [];
/**
* Attributes for Tatter\Handlers.
*
* @var array
*/
protected $attributes = [];

/**
* Checks for and merges default attributes.
*/
public function __construct()
{
if (property_exists($this, 'defaults') && is_array($this->defaults))
{
$this->attributes = array_merge($this->defaults, $this->attributes);
}
}
/**
* Checks for and merges default attributes.
*/
public function __construct()
{
if (property_exists($this, 'defaults') && is_array($this->defaults)) {
$this->attributes = array_merge($this->defaults, $this->attributes);
}
}
}
72 changes: 34 additions & 38 deletions src/Commands/HandlersList.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,38 @@

class HandlersList extends BaseCommand
{
protected $group = 'Housekeeping';
protected $name = 'handlers:list';
protected $description = 'List all discovered handlers';
protected $usage = 'handlers:list';

public function run(array $params = [])
{
// Load the library
$handlers = new Handlers();

// Make sure auto-discovery is enabled
if (empty($handlers->getConfig()->autoDiscover))
{
CLI::write('No paths are set for automatic discovery. See the config file for Tatter\Handlers.', 'yellow');

return;
}

// Process each path
foreach ($handlers->getConfig()->autoDiscover as $path)
{
$handlers->setPath($path);
CLI::write($path, 'black', 'light_gray');

if (! $classes = $handlers->findAll())
{
CLI::write('No handlers detected.', 'yellow');

continue;
}

// Display each class
foreach ($classes as $class)
{
CLI::write($class);
}
}
}
protected $group = 'Housekeeping';
protected $name = 'handlers:list';
protected $description = 'List all discovered handlers';
protected $usage = 'handlers:list';

public function run(array $params = [])
{
// Load the library
$handlers = new Handlers();

// Make sure auto-discovery is enabled
if (empty($handlers->getConfig()->autoDiscover)) {
CLI::write('No paths are set for automatic discovery. See the config file for Tatter\Handlers.', 'yellow');

return;
}

// Process each path
foreach ($handlers->getConfig()->autoDiscover as $path) {
$handlers->setPath($path);
CLI::write($path, 'black', 'light_gray');

if (! $classes = $handlers->findAll()) {
CLI::write('No handlers detected.', 'yellow');

continue;
}

// Display each class
foreach ($classes as $class) {
CLI::write($class);
}
}
}
}
72 changes: 34 additions & 38 deletions src/Commands/HandlersRegister.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,38 @@

class HandlersRegister extends BaseCommand
{
protected $group = 'Housekeeping';
protected $name = 'handlers:register';
protected $description = 'Regsiter all discovered handlers';
protected $usage = 'handlers:register';

public function run(array $params = [])
{
// Load the library
$handlers = new Handlers();

// Make sure auto-discovery is enabled
if (empty($handlers->getConfig()->autoDiscover))
{
CLI::write('No paths are set for automatic discovery. See the config file for Tatter\Handlers.', 'yellow');

return;
}

// Process each path
foreach ($handlers->getConfig()->autoDiscover as $path)
{
$handlers->setPath($path);
CLI::write($path, 'black', 'light_gray');

if (! $classes = $handlers->findAll())
{
CLI::write('No new handlers registered.', 'yellow');

continue;
}

// Display each class
foreach ($classes as $class)
{
CLI::write($class);
}
}
}
protected $group = 'Housekeeping';
protected $name = 'handlers:register';
protected $description = 'Regsiter all discovered handlers';
protected $usage = 'handlers:register';

public function run(array $params = [])
{
// Load the library
$handlers = new Handlers();

// Make sure auto-discovery is enabled
if (empty($handlers->getConfig()->autoDiscover)) {
CLI::write('No paths are set for automatic discovery. See the config file for Tatter\Handlers.', 'yellow');

return;
}

// Process each path
foreach ($handlers->getConfig()->autoDiscover as $path) {
$handlers->setPath($path);
CLI::write($path, 'black', 'light_gray');

if (! $classes = $handlers->findAll()) {
CLI::write('No new handlers registered.', 'yellow');

continue;
}

// Display each class
foreach ($classes as $class) {
CLI::write($class);
}
}
}
}
52 changes: 25 additions & 27 deletions src/Commands/HandlersReset.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,29 @@

class HandlersReset extends BaseCommand
{
protected $group = 'Housekeeping';
protected $name = 'handlers:reset';
protected $description = 'Clear cached versions of discovered handlers';
protected $usage = 'handlers:reset';

public function run(array $params = [])
{
// Load the library
$handlers = new Handlers();

// Make sure auto-discovery is enabled
if (empty($handlers->getConfig()->autoDiscover))
{
CLI::write('No paths are set for automatic discovery. See the config file for Tatter\Handlers.', 'yellow');

return;
}

// Process each path
foreach ($handlers->getConfig()->autoDiscover as $path)
{
$handlers->setPath($path);
$handlers->cacheClear();
}

CLI::write('All cached handlers cleared!', 'green');
}
protected $group = 'Housekeeping';
protected $name = 'handlers:reset';
protected $description = 'Clear cached versions of discovered handlers';
protected $usage = 'handlers:reset';

public function run(array $params = [])
{
// Load the library
$handlers = new Handlers();

// Make sure auto-discovery is enabled
if (empty($handlers->getConfig()->autoDiscover)) {
CLI::write('No paths are set for automatic discovery. See the config file for Tatter\Handlers.', 'yellow');

return;
}

// Process each path
foreach ($handlers->getConfig()->autoDiscover as $path) {
$handlers->setPath($path);
$handlers->cacheClear();
}

CLI::write('All cached handlers cleared!', 'green');
}
}
38 changes: 19 additions & 19 deletions src/Config/Handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@

class Handlers extends BaseConfig
{
/**
* Classes to ignore across all handlers.
*
* @var array<string>
*/
public $ignoredClasses = [];
/**
* Classes to ignore across all handlers.
*
* @var array<string>
*/
public $ignoredClasses = [];

/**
* Paths to check during automatic discovery.
*
* @var array<string>
*/
public $autoDiscover = [];
/**
* Paths to check during automatic discovery.
*
* @var array<string>
*/
public $autoDiscover = [];

/**
* Number of seconds to cache discovered handlers.
* Null disables caching
*
* @var int|null
*/
public $cacheDuration = DAY;
/**
* Number of seconds to cache discovered handlers.
* Null disables caching
*
* @var int|null
*/
public $cacheDuration = DAY;
}

0 comments on commit e6f273c

Please sign in to comment.