Skip to content

Commit dae5c6d

Browse files
author
midesweb
committed
php cs fixer
1 parent f2779d4 commit dae5c6d

17 files changed

+786
-707
lines changed

.php-cs-fixer.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"php":"8.3.23","version":"3.93.0:v3.93.0#50895a07cface1385082e4caa6a6786c4e033468","indent":" ","lineEnding":"\n","rules":{"nullable_type_declaration":true,"operator_linebreak":true,"ordered_types":{"null_adjustment":"always_last"},"single_class_element_per_statement":true,"types_spaces":true,"array_indentation":true,"array_syntax":true,"attribute_block_no_spaces":true,"cast_spaces":true,"concat_space":true,"function_declaration":{"closure_fn_spacing":"one"},"method_argument_space":{"after_heredoc":true,"on_multiline":"ensure_fully_multiline"},"new_with_parentheses":{"anonymous_class":false},"single_line_empty_body":true,"single_space_around_construct":true,"trailing_comma_in_multiline":{"after_heredoc":true,"elements":["array_destructuring","arrays"]},"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_anonymous_functions":true,"allow_single_line_empty_anonymous_classes":true},"class_definition":{"single_line":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"modifier_keywords":true,"no_blank_lines_after_class_opening":true,"no_extra_blank_lines":{"tokens":["attribute","break","case","continue","curly_brace_block","default","extra","parenthesis_brace_block","return","square_brace_block","switch","throw","use"]},"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":true,"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":{"stick_comment_to_next_continuous_control_statement":true},"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"octal_notation":true,"clean_namespace":true,"no_unset_cast":true,"assign_null_coalescing_to_coalesce_equal":true,"normalize_index_brace":true,"heredoc_indentation":true,"no_whitespace_before_comma_in_array":{"after_heredoc":true},"list_syntax":true,"ternary_to_null_coalescing":true,"no_trailing_whitespace_in_string":true,"no_unreachable_default_argument_value":true,"get_class_to_class_keyword":true,"modernize_strpos":true,"no_alias_functions":{"sets":["@all"]},"no_php4_constructor":true,"no_unneeded_final_method":true,"implode_call":true,"use_arrow_functions":true,"void_return":true,"combine_nested_dirname":true,"declare_strict_types":true,"non_printable_character":true,"random_api_migration":{"replacements":{"mt_getrandmax":"getrandmax","mt_rand":"random_int","mt_srand":"srand","rand":"random_int"}},"pow_to_exponentiation":true,"php_unit_data_provider_static":{"force":true},"php_unit_assert_new_names":true,"php_unit_expectation":{"target":"8.4"},"php_unit_dedicate_assert_internal_type":{"target":"7.5"},"php_unit_namespaced":{"target":"6.0"},"php_unit_dedicate_assert":{"target":"5.6"},"php_unit_mock":{"target":"5.5"},"php_unit_no_expectation_annotation":{"target":"4.3"},"blank_line_before_statement":{"statements":["break","case","continue","declare","default","exit","goto","include","include_once","phpdoc","require","require_once","return","switch","throw","try","yield","yield_from"]},"combine_consecutive_issets":true,"combine_consecutive_unsets":true,"empty_loop_body":true,"explicit_indirect_variable":true,"explicit_string_variable":true,"fully_qualified_strict_types":{"import_symbols":true},"heredoc_to_nowdoc":true,"method_chaining_indentation":true,"multiline_comment_opening_closing":true,"multiline_whitespace_before_semicolons":{"strategy":"new_line_for_chained_calls"},"no_superfluous_elseif":true,"no_superfluous_phpdoc_tags":{"allow_hidden_params":true,"allow_mixed":true,"remove_inheritdoc":true},"php_unit_data_provider_method_order":true,"php_unit_internal_class":true,"php_unit_test_class_requires_covers":true,"phpdoc_add_missing_param_annotation":true,"phpdoc_no_empty_return":true,"phpdoc_order_by_value":true,"phpdoc_types_no_duplicates":true,"phpdoc_types_order":true,"return_assignment":true,"self_static_accessor":true,"single_line_comment_style":true,"string_implicit_backslashes":true,"whitespace_after_comma_in_array":{"ensure_single_space":true},"align_multiline_comment":true,"backtick_to_shell_exec":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_reference_name_casing":true,"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_condition":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"global_namespace_import":{"import_classes":false,"import_constants":false,"import_functions":false},"include":true,"increment_style":true,"integer_literal_case":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"native_function_casing":true,"native_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_null_property_initialization":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_trailing_comma_in_singleline":true,"no_unneeded_braces":{"namespaces":true},"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","negative_instanceof","others","return","switch_case","yield","yield_from"]},"no_unneeded_import_alias":true,"no_unused_imports":true,"no_useless_concat_operator":true,"no_useless_else":true,"no_useless_nullsafe_operator":true,"no_useless_return":true,"nullable_type_declaration_for_default_null_value":true,"object_operator_without_whitespace":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":{"replacements":{"const":"var","link":"see","property-read":"property","property-write":"property","type":"var"}},"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_order":{"order":["param","return","throws"]},"phpdoc_return_self_reference":true,"phpdoc_scalar":{"types":["boolean","callback","double","integer","never-return","never-returns","no-return","real","str"]},"phpdoc_separation":{"groups":[["Annotation","NamedArgumentConstructor","Target"],["author","copyright","license"],["category","package","subpackage"],["property","property-read","property-write"],["deprecated","link","see","since"]],"skip_unlisted_annotations":false},"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":{"allow_before_return_statement":false},"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_var_annotation_correct_order":true,"phpdoc_var_without_name":true,"protected_to_private":true,"semicolon_after_instruction":true,"simple_to_complex_string_variable":true,"single_line_comment_spacing":true,"single_quote":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trim_array_spaces":true,"type_declaration_spaces":{"elements":["function","property"]},"yoda_style":true},"ruleCustomisationPolicyVersion":"null-policy","hashes":{"src\/ApiKitServiceProvider.php":"af76edfad4dfa3b744c549fa3e5e885d","src\/Exceptions\/CustomFilterNameNotDefinedException.php":"a201a6e289dffe564b3c5d433fc3ca08","src\/Exceptions\/ListModelNotDefinedException.php":"3105d10cbf3cc24f9ef579087851b369","src\/ListService.php":"6f98f94590aa20b0de22511a8b46210a","src\/CustomFilter.php":"a71b5c9dd43f75b491cfdcde09722809","src\/ResourceListable.php":"03d26f7b1ffecc42789e8deb34557b2c","tests\/Filters\/TitleContainsFilter.php":"3e180889754fd0e18c11192bfb1270b8","tests\/Database\/migrations\/2026_01_23_000000_create_posts_table.php":"d2af93acf408f403951819c115af7e3d","tests\/Database\/migrations\/2026_01_23_000001_create_comments_table.php":"491ac6d4c851b779e96bb0aae8d81bc5","tests\/Database\/Factories\/CommentFactory.php":"b438126e778db7cbb0df8e1176470ab4","tests\/Database\/Factories\/PostFactory.php":"99e1d8b181eaffd0eaa2af990f7b0abd","tests\/ResourceListableTest.php":"3772c49ca03547c8758e1fed86574521","tests\/ListServiceTest.php":"83303f82489fbdd7fc8c05de18bc08a9","tests\/Fixtures\/Post.php":"1a0e368ee39b65a08368bc98f4461365","tests\/Fixtures\/Comment.php":"5f117b1006364788483abc5b29bbc5db","tests\/TestCase.php":"b3b17f7ddfa2bd72d57e5a6c35291fde"}}

src/ApiKitServiceProvider.php

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

3+
declare(strict_types=1);
4+
35
namespace EscuelaIT\APIKit;
46

57
use Illuminate\Support\ServiceProvider;
68

79
class ApiKitServiceProvider extends ServiceProvider
810
{
9-
public function boot()
11+
public function boot(): void
1012
{
11-
// ...
13+
// ...
1214
}
1315

14-
public function register()
16+
public function register(): void
1517
{
16-
// ...
18+
// ...
1719
}
1820
}

src/CustomFilter.php

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

3+
declare(strict_types=1);
4+
35
namespace EscuelaIT\APIKit;
46

5-
use Illuminate\Database\Eloquent\Builder;
67
use EscuelaIT\APIKit\Exceptions\CustomFilterNameNotDefinedException;
8+
use Illuminate\Database\Eloquent\Builder;
79

810
abstract class CustomFilter
911
{
10-
1112
protected $searchConfiguration;
1213
protected $filterName;
1314

1415
public function applyCustomFilter(Builder $query, array $searchConfiguration): void
1516
{
16-
if (!is_string($this->filterName) || trim((string) $this->filterName) === '') {
17+
if (!is_string($this->filterName) || '' === trim((string) $this->filterName)) {
1718
throw new CustomFilterNameNotDefinedException(static::class);
1819
}
1920

2021
$this->searchConfiguration = $searchConfiguration;
21-
if($this->isFilterActive()) {
22+
if ($this->isFilterActive()) {
2223
$this->apply($query);
2324
}
2425
}
@@ -28,32 +29,34 @@ public function getFilterName(): string
2829
return $this->filterName;
2930
}
3031

32+
/**
33+
* Apply the filter to the query.
34+
*
35+
* @param Builder $query The Laravel query builder
36+
*/
37+
abstract public function apply(Builder $query): void;
38+
3139
protected function getFilterData()
3240
{
3341
$filtered = array_filter(
3442
$this->searchConfiguration['filters'],
35-
fn($filter) => $filter->name === $this->filterName
43+
fn ($filter) => $filter->name === $this->filterName
3644
);
45+
3746
return reset($filtered) ?: null;
3847
}
3948

4049
protected function isFilterActive(): bool
4150
{
4251
$filter = $this->getFilterData();
52+
4353
return $filter ? $filter->active : false;
4454
}
4555

4656
protected function getFilterValue()
4757
{
4858
$filter = $this->getFilterData();
49-
return $filter ? $filter->value : null;
50-
}
5159

52-
/**
53-
* Apply the filter to the query
54-
*
55-
* @param Builder $query The Laravel query builder
56-
* @return void
57-
*/
58-
abstract public function apply(Builder $query): void;
60+
return $filter ? $filter->value : null;
61+
}
5962
}

src/Exceptions/CustomFilterNameNotDefinedException.php

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

3-
namespace EscuelaIT\APIKit\Exceptions;
3+
declare(strict_types=1);
44

5-
use Exception;
5+
namespace EscuelaIT\APIKit\Exceptions;
66

7-
class CustomFilterNameNotDefinedException extends Exception
7+
class CustomFilterNameNotDefinedException extends \Exception
88
{
9-
public function __construct(string $class = "")
9+
public function __construct(string $class = '')
1010
{
11-
$message = 'The \'filterName\' property is not defined or empty in the ' . $class . ' custom filter. '
12-
. 'Every CustomFilter must set a non-empty \"filterName\" property (e.g., protected $filterName = \"my_filter\").';
11+
$message = 'The \'filterName\' property is not defined or empty in the '.$class.' custom filter. '
12+
.'Every CustomFilter must set a non-empty \"filterName\" property (e.g., protected $filterName = \"my_filter\").';
1313

1414
parent::__construct($message);
1515
}

src/Exceptions/ListModelNotDefinedException.php

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

3-
namespace EscuelaIT\APIKit\Exceptions;
3+
declare(strict_types=1);
44

5-
use Exception;
5+
namespace EscuelaIT\APIKit\Exceptions;
66

7-
class ListModelNotDefinedException extends Exception
7+
class ListModelNotDefinedException extends \Exception
88
{
9-
public function __construct(string $class = "")
9+
public function __construct(string $class = '')
1010
{
1111
$message = "The 'listModel' property is not defined in the {$class} class. "
12-
. "You must define the model to use in your ListService derived class.";
12+
.'You must define the model to use in your ListService derived class.';
1313

1414
parent::__construct($message);
1515
}

0 commit comments

Comments
 (0)