Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
Merge 0c4911d into b2cf688
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgall committed Apr 3, 2020
2 parents b2cf688 + 0c4911d commit 8b1d3e7
Show file tree
Hide file tree
Showing 8 changed files with 783 additions and 564 deletions.
156 changes: 156 additions & 0 deletions .php_cs
@@ -0,0 +1,156 @@
<?php

/**
* PHP-CS-Fixer v2.16.1 fixers/rules.
*
* Install PHP-CS-Fixer globally w/ composer by running:
* composer global require friendsofphp/php-cs-fixer
*
* @example php-cs-fixer fix --show-progress
*
* @author Erik Galloway <egalloway@claruscare.com>
*/
$fixers = [
'align_multiline_comment' => ['comment_type'=>'phpdocs_only'],
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'align_equals' => false,
'align_double_arrow' => true,
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => true,
'braces' => true,
'cast_spaces' => true,
'class_attributes_separation' => true,
'class_definition' => true,
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'none'],
'constant_case' => true,
'elseif' => true,
'encoding' => true,
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'full_opening_tag' => true,
'fully_qualified_strict_types' => true,
'function_declaration' => true,
'function_typehint_space' => true,
'include' => true,
'indentation_type' => true,
'line_ending' => true,
'list_syntax' => ['syntax' => 'short'],
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
],
'method_chaining_indentation' => true,
'multiline_whitespace_before_semicolons' => true,
'native_function_casing' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_break_comment' => true,
'no_closing_tag' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_null_property_initialization' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'not_operator_with_successor_space' => true,
'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true],
'object_operator_without_whitespace' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'destruct',
'phpunit',
'method_public',
'method_public_static',
'magic',
'method_protected',
'method_protected_static',
'method_private',
'method_private_static',
],
'sortAlgorithm' => 'alpha',
],
'ordered_imports' => ['sortAlgorithm' => 'length'],
'php_unit_method_casing' => ['case' => 'snake_case'],
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_summary' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true,
'return_assignment' => true,
'return_type_declaration' => ['space_before' => 'none'],
'short_scalar_cast' => true,
'simple_to_complex_string_variable' => true,
'simplified_null_return' => true,
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => ['elements' => ['property']],
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
'void_return' => true,
];

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude(['bootstrap', 'storage', 'vendor', 'tests'])
->notPath('server.php')
->notPath('public/index.php');

return PhpCsFixer\Config::create()
->setUsingCache(false)
->setRules($fixers)
->setRiskyAllowed(true)
->setFinder($finder);
10 changes: 5 additions & 5 deletions composer.json
Expand Up @@ -10,10 +10,10 @@
}],
"require": {
"php": ">=7.2",
"illuminate/database": "~5.5|~6.0",
"illuminate/support": "~5.5|~6.0",
"illuminate/console": "~5.5|~6.0",
"illuminate/events": "~5.5|~6.0"
"illuminate/database": "~5.5|~6.0|~7.0",
"illuminate/support": "~5.5|~6.0|~7.0",
"illuminate/console": "~5.5|~6.0|~7.0",
"illuminate/events": "~5.5|~6.0|~7.0"
},
"require-dev": {
"phpunit/phpunit": "~8.0",
Expand All @@ -38,4 +38,4 @@
]
}
}
}
}
31 changes: 0 additions & 31 deletions resources/views/migration.php

This file was deleted.

71 changes: 39 additions & 32 deletions src/Config.php
Expand Up @@ -6,43 +6,51 @@

class Config
{
const POSITION_TOP = 'top';
const ADD_NEW_ITEM_TO_KEY = 'addNewItemTo';

const POSITION_BOTTOM = 'bottom';

const TOP_POSITION_IN_LIST_KEY = 'topPositionInList';
const POSITION_COLUMN_NAME_KEY = 'positionColumnName';

const POSITION_TOP = 'top';

const SCOPE_KEY = 'scope';
const ADD_NEW_ITEM_TO_KEY = 'addNewItemTo';

protected $defaultTopPositionInList = 1;
const TOP_POSITION_IN_LIST_KEY = 'topPositionInList';

protected $config = [];

protected $defaultAddNewItemTo = self::POSITION_BOTTOM;

protected $defaultPositionColumnName = 'position';

protected $defaultScope = '1 = 1';
protected $defaultAddNewItemTo = self::POSITION_BOTTOM;

protected $config = [];
protected $defaultTopPositionInList = 1;

public function __construct()
{
$this->config = $this->buildDefaultConfig();
}

public function setTopPositionInList($position)
public function getAddNewItemTo()
{
if (! is_int($position)) {
throw new InvalidArgumentException('Only integers are allowed.');
}
return $this->get(self::ADD_NEW_ITEM_TO_KEY);
}

return $this->set(self::TOP_POSITION_IN_LIST_KEY, $position);
public function getPositionColumnName()
{
return $this->get(self::POSITION_COLUMN_NAME_KEY);
}

public function setPositionColumnName($name)
public function getScope()
{
return $this->set(self::POSITION_COLUMN_NAME_KEY, $name);
return $this->get(self::SCOPE_KEY);
}

public function setScope($scope)
public function getTopPositionInList()
{
return $this->set(self::SCOPE_KEY, $scope);
return $this->get(self::TOP_POSITION_IN_LIST_KEY);
}

public function setAddNewItemTo($listPosition)
Expand All @@ -54,33 +62,39 @@ public function setAddNewItemTo($listPosition)
return $this->set(self::ADD_NEW_ITEM_TO_KEY, $listPosition);
}

public function getTopPositionInList()
public function setPositionColumnName($name)
{
return $this->get(self::TOP_POSITION_IN_LIST_KEY);
return $this->set(self::POSITION_COLUMN_NAME_KEY, $name);
}

public function getPositionColumnName()
public function setScope($scope)
{
return $this->get(self::POSITION_COLUMN_NAME_KEY);
return $this->set(self::SCOPE_KEY, $scope);
}

public function getScope()
public function setTopPositionInList($position)
{
return $this->get(self::SCOPE_KEY);
if (! is_int($position)) {
throw new InvalidArgumentException('Only integers are allowed.');
}

return $this->set(self::TOP_POSITION_IN_LIST_KEY, $position);
}

public function getAddNewItemTo()
protected function assertKeyIsValid($key): void
{
return $this->get(self::ADD_NEW_ITEM_TO_KEY);
if (! in_array($key, $this->validKeys())) {
throw new InvalidArgumentException("Key '{$key}' is invalid.");
}
}

protected function buildDefaultConfig()
{
return [
self::TOP_POSITION_IN_LIST_KEY => $this->defaultTopPositionInList,
self::POSITION_COLUMN_NAME_KEY => $this->defaultPositionColumnName,
self::SCOPE_KEY => $this->defaultScope,
self::ADD_NEW_ITEM_TO_KEY => $this->defaultAddNewItemTo,
self::SCOPE_KEY => $this->defaultScope,
self::ADD_NEW_ITEM_TO_KEY => $this->defaultAddNewItemTo,
];
}

Expand All @@ -99,13 +113,6 @@ protected function set($key, $value)
return $this;
}

protected function assertKeyIsValid($key)
{
if (! in_array($key, $this->validKeys())) {
throw new InvalidArgumentException("Key '$key' is invalid.");
}
}

protected function validKeys()
{
return [self::TOP_POSITION_IN_LIST_KEY, self::POSITION_COLUMN_NAME_KEY, self::SCOPE_KEY, self::ADD_NEW_ITEM_TO_KEY];
Expand Down

0 comments on commit 8b1d3e7

Please sign in to comment.