Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
d0986dd
Components: added parameter types + return types
TimLibaro Aug 5, 2022
3e7fac5
Component: added return types
TimLibaro Aug 5, 2022
8cefb8f
added phpdoc for return types : mixed
TimLibaro Aug 5, 2022
a4e9be8
Field $type has to be string + update for all field types
TimLibaro Aug 5, 2022
78f17e1
Fix styling
TimLibaro Aug 5, 2022
b3a4ec9
added types for class, overwrite and options
TimLibaro Aug 5, 2022
3e20d7f
Fix styling
TimLibaro Aug 5, 2022
b85c32c
bugfix
TimLibaro Aug 5, 2022
5487f71
Header: added parameter and return types
TimLibaro Aug 5, 2022
f3699fe
Filter: added parameter and return types
TimLibaro Aug 5, 2022
132a407
Fix styling
TimLibaro Aug 5, 2022
577175e
added parameter + return types for Contracts classes
TimLibaro Aug 5, 2022
6fd70e7
Fix styling
TimLibaro Aug 5, 2022
8de01cd
added phpdoc typehint
TimLibaro Aug 5, 2022
fc942e2
FilterService : added phpdoc typehint
TimLibaro Aug 5, 2022
130be27
added parameter type
TimLibaro Aug 5, 2022
130f5c7
Fix styling
TimLibaro Aug 5, 2022
b805603
added return and parameter types
TimLibaro Aug 5, 2022
b134e0c
added types
TimLibaro Aug 5, 2022
aff4e1c
Fix styling
TimLibaro Aug 5, 2022
c67f1d6
updated phpstan level 5 to level 6
TimLibaro Aug 5, 2022
1d43e68
added return types + argument types + global var types
TimLibaro Aug 19, 2022
4acd513
Fix styling
TimLibaro Aug 19, 2022
25d794f
added return type
TimLibaro Aug 19, 2022
79f6cbc
added return type
TimLibaro Aug 19, 2022
2da4b7f
added return types
TimLibaro Aug 19, 2022
8a8a883
Fix styling
TimLibaro Aug 19, 2022
967c6ef
added return types
TimLibaro Aug 19, 2022
00deb5e
Fix styling
TimLibaro Aug 19, 2022
40b9cc1
added return types + argument type
TimLibaro Aug 19, 2022
afe37e0
Fix styling
TimLibaro Aug 19, 2022
9acab11
added return types
TimLibaro Aug 19, 2022
37b2c49
added return type Boolean
TimLibaro Aug 19, 2022
a02e9ab
Fix styling
TimLibaro Aug 19, 2022
817bba3
added argument type + return types
TimLibaro Aug 19, 2022
3aa516f
Fix styling
TimLibaro Aug 19, 2022
3bf146c
added return types + argument types
TimLibaro Aug 19, 2022
1c38745
Fix styling
TimLibaro Aug 19, 2022
629650e
added return types + argument types
TimLibaro Aug 19, 2022
0f00093
marked inconsequences in the code with a TODO
TimLibaro Aug 19, 2022
2e7f4fa
Fix styling
TimLibaro Aug 19, 2022
2c2a9eb
added return type
TimLibaro Aug 19, 2022
8d44d89
Fix styling
TimLibaro Aug 19, 2022
df20a4d
argument + return types
TimLibaro Aug 19, 2022
85c8e82
Fix styling
TimLibaro Aug 19, 2022
7dc8d74
added argument + return types
TimLibaro Aug 19, 2022
1304af6
Fix styling
TimLibaro Aug 19, 2022
3a5d0ce
fix for Property Libaro\Bread\Contracts\Field::$options (array) does…
TimLibaro Aug 19, 2022
4fbf3d4
Fix styling
TimLibaro Aug 19, 2022
77bbc5e
added return types + argument types
TimLibaro Aug 19, 2022
191ca52
Fix styling
TimLibaro Aug 19, 2022
f6798ff
added types
TimLibaro Aug 19, 2022
840e007
Fix styling
TimLibaro Aug 19, 2022
95733c3
added return type
TimLibaro Aug 19, 2022
3dabf2d
Fix styling
TimLibaro Aug 19, 2022
40e41cc
added types
TimLibaro Aug 19, 2022
48b3628
Fix styling
TimLibaro Aug 19, 2022
cb99214
added types
TimLibaro Aug 19, 2022
9077adf
Fix styling
TimLibaro Aug 19, 2022
917fd18
added types
TimLibaro Aug 19, 2022
bea7e18
Fix styling
TimLibaro Aug 19, 2022
11e0fb4
added types
TimLibaro Aug 19, 2022
97d7b95
Fix styling
TimLibaro Aug 19, 2022
7722ddc
added types
TimLibaro Aug 19, 2022
5e2bdb8
Fix styling
TimLibaro Aug 19, 2022
0e943d4
phpstan level 6 => 7
TimLibaro Aug 19, 2022
2ee3ca2
foreach needs iterable
TimLibaro Aug 19, 2022
09833f9
Fix styling
TimLibaro Aug 19, 2022
a214709
added TODO comment for hard to fix phpstan warnings
TimLibaro Aug 26, 2022
97ae3e3
Fix styling
TimLibaro Aug 26, 2022
e6b5964
cast to bool
TimLibaro Aug 26, 2022
6041918
Fix styling
TimLibaro Aug 26, 2022
df25392
fixed : Part $name (array|bool|string) of encapsed string cannot be c…
TimLibaro Aug 26, 2022
f748be4
fixed mixed return types
TimLibaro Aug 26, 2022
7b5c10c
Fix styling
TimLibaro Aug 26, 2022
ddce1dc
fixed argument params types
TimLibaro Aug 26, 2022
c77646a
Fix styling
TimLibaro Aug 26, 2022
612a0d3
ignoring 2 phpstan level 7 warnings that are hard to fix
TimLibaro Aug 26, 2022
51030cb
Fix styling
TimLibaro Aug 26, 2022
aaad2a3
Cannot use array destructuring on array|null.
TimLibaro Aug 26, 2022
ab5142f
check for null
TimLibaro Aug 26, 2022
e32c3f1
Fix styling
TimLibaro Aug 26, 2022
cbe551e
config for phstan level 9
TimLibaro Aug 26, 2022
de8ec99
check if var is mixed
TimLibaro Aug 26, 2022
847e32f
Fix styling
TimLibaro Aug 26, 2022
d3bc0a5
phpstan level 9
TimLibaro Sep 2, 2022
aae9694
phpstan level 9
TimLibaro Sep 2, 2022
8d1da33
phpstan level 9
TimLibaro Sep 2, 2022
92b7197
Fix styling
TimLibaro Sep 2, 2022
96ac6cc
phpstan level 9
TimLibaro Sep 2, 2022
ee6a6b6
phpstan level 9
TimLibaro Sep 2, 2022
6083070
phpstan level 9
TimLibaro Sep 2, 2022
fe44a46
phpstan level 9
TimLibaro Sep 2, 2022
5933de8
phpstan level 9
TimLibaro Sep 2, 2022
c9f87e2
Fix styling
TimLibaro Sep 2, 2022
82c1cad
phpstan level 9
TimLibaro Sep 2, 2022
cc05d15
phpstan level 9
TimLibaro Sep 2, 2022
5128964
phpstan level 9
TimLibaro Sep 2, 2022
32517bf
Fix styling
TimLibaro Sep 2, 2022
14b1a79
phpstan level 9
TimLibaro Sep 2, 2022
7ec39b8
phpstan level 9
TimLibaro Sep 2, 2022
a89dd09
phpstan level 9
TimLibaro Sep 2, 2022
583afd8
Fix styling
TimLibaro Sep 2, 2022
2e1e5dd
phpstan level 9
TimLibaro Sep 2, 2022
4011e3f
phpstan level 9
TimLibaro Sep 2, 2022
c73ea5c
Fix styling
TimLibaro Sep 2, 2022
e79f3aa
phpstan level 9 : zero errors
TimLibaro Sep 2, 2022
7d56b82
Fix styling
TimLibaro Sep 2, 2022
e707957
Optional cannot be used in combination with mixed an toArray
johan-libaro Sep 9, 2022
2817da8
Use static render method on Inertia class
johan-libaro Sep 9, 2022
4df59f3
Add return type
johan-libaro Sep 9, 2022
eed10a1
Codestyle
johan-libaro Sep 9, 2022
4c021c5
Use static render method on Inertia class
johan-libaro Sep 9, 2022
e69c235
Optional cannot be used in combination with mixed an toArray
johan-libaro Sep 9, 2022
c7a0d03
Set type to Fields
johan-libaro Sep 9, 2022
5cf5cfb
Codestyle
johan-libaro Sep 9, 2022
fd93579
Ignore phpstan warning toArray on mixed
johan-libaro Sep 9, 2022
85f337e
Make collection typed
johan-libaro Sep 9, 2022
7676e46
Codestyle
johan-libaro Sep 9, 2022
3019c7d
Fix styling
johan-libaro Sep 9, 2022
35fb48c
Remove todo comments
johan-libaro Sep 9, 2022
f3e0b8f
Fix styling
johan-libaro Sep 9, 2022
b759e40
reverted breaking changes, while still passing phpstan validations
TimLibaro Sep 9, 2022
9431be2
Fix styling
TimLibaro Sep 9, 2022
b77456c
code cleanup
TimLibaro Sep 9, 2022
e2bfc47
Fix styling
TimLibaro Sep 9, 2022
6c54d7a
made collection typed for map
TimLibaro Sep 9, 2022
d2adbfe
Fix styling
TimLibaro Sep 9, 2022
2b28faa
made collection typed for ->map(...)
TimLibaro Sep 9, 2022
fcf84c6
Fix styling
TimLibaro Sep 9, 2022
1915cc5
made collection typed for ->map(...)
TimLibaro Sep 9, 2022
6f9f51e
Fix styling
TimLibaro Sep 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .php-cs-fixer.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"php":"8.1.8","version":"3.9.5","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Components\/Components.php":4113470597,"src\/ValueObjects\/Types.php":976112391,"src\/Fields\/Image.php":3475913326,"src\/Fields\/Text.php":1843933408,"src\/Fields\/Fields.php":3082770791,"src\/Fields\/Boolean.php":288662375,"src\/Fields\/Tabs.php":2338077135,"src\/Fields\/Select.php":2468598124,"src\/Fields\/Tab.php":122323775,"src\/Fields\/MultiSelect.php":2967987406,"src\/Fields\/Number.php":2972592454,"src\/Contracts\/Field.php":3529337728,"src\/Contracts\/Route.php":1966485194,"src\/Contracts\/IndexComponents.php":1435574258,"src\/Contracts\/Invokables.php":1570910920,"src\/Contracts\/Filter.php":1482797957,"src\/Contracts\/Header.php":3412176535,"src\/Contracts\/FormComponents.php":2006127091,"src\/Contracts\/ComponentsInterface.php":39333525,"src\/Contracts\/Component.php":4154481113,"src\/Contracts\/Renderer.php":3899250064,"src\/Services\/CreateCustomService.php":2751149137,"src\/Services\/FilterService.php":1136423926,"src\/Services\/SortingService.php":971942833,"src\/BreadServiceProvider.php":3682323247,"src\/Routes\/Destroy.php":392466729,"src\/Routes\/Create.php":3261679531,"src\/Routes\/Index.php":2467093646,"src\/Routes\/Edit.php":3380151641,"src\/Routes\/Store.php":901166628,"src\/Routes\/Routes.php":1567158451,"src\/Routes\/Update.php":1183005567,"src\/Filters\/Text.php":4047841771,"src\/Filters\/Filter.php":1453482139,"src\/Filters\/Boolean.php":1579975008,"src\/Filters\/Filters.php":3143774296,"src\/Filters\/Select.php":412827139,"src\/Headers\/Date.php":801899764,"src\/Headers\/Text.php":1963652945,"src\/Headers\/Headers.php":3282279307,"src\/Headers\/Boolean.php":3260714470,"src\/Headers\/Trend.php":1947377138,"src\/Headers\/Link.php":3399789503,"src\/Headers\/Set.php":186843820,"src\/Headers\/Money.php":3303539918,"src\/Headers\/Download.php":2796001948,"src\/Headers\/Rating.php":1094539246,"src\/Headers\/Label.php":3381470344,"src\/Headers\/InertiaLink.php":3761921318,"src\/Headers\/Number.php":844704962,"src\/Commands\/CreateCustomField.php":1830559918,"src\/Commands\/CreateCustomHeader.php":1362670939,"src\/Commands\/CreateCustomFilter.php":2772280546,"src\/Renderers\/FormRenderer.php":119095043,"src\/Renderers\/IndexRenderer.php":144237398,"tests\/Pest.php":1399058707,"tests\/TestCase.php":51090682}}
{"php":"8.1.10","version":"3.11.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Services\/FilterService.php":3242563327,"src\/Services\/SortingService.php":570185584,"src\/Services\/CreateCustomService.php":3045546300,"src\/ValueObjects\/Types.php":976112391,"src\/BreadServiceProvider.php":3682323247,"src\/Contracts\/Component.php":413477820,"src\/Contracts\/Route.php":1994232514,"src\/Contracts\/Header.php":1729022448,"src\/Contracts\/Invokables.php":3589802302,"src\/Contracts\/FormComponents.php":2006127091,"src\/Contracts\/Renderer.php":2450971325,"src\/Contracts\/Field.php":4212146176,"src\/Contracts\/ComponentsInterface.php":957920066,"src\/Contracts\/IndexComponents.php":1435574258,"src\/Contracts\/Filter.php":2143273424,"src\/Routes\/Create.php":1695394094,"src\/Routes\/Destroy.php":1458008311,"src\/Routes\/Update.php":4166386385,"src\/Routes\/Store.php":460891973,"src\/Routes\/Routes.php":2675183373,"src\/Routes\/Index.php":2907359599,"src\/Routes\/Edit.php":3991995671,"src\/Filters\/Filters.php":3707575036,"src\/Filters\/Text.php":1721742153,"src\/Filters\/Boolean.php":1951698771,"src\/Filters\/Select.php":3820557334,"src\/Filters\/Filter.php":1213338388,"src\/Commands\/CreateCustomFilter.php":1671250702,"src\/Commands\/CreateCustomHeader.php":250823473,"src\/Commands\/CreateCustomField.php":4000417138,"src\/Renderers\/IndexRenderer.php":1195470683,"src\/Renderers\/FormRenderer.php":1601248856,"src\/Fields\/Number.php":124780854,"src\/Fields\/MultiSelect.php":2655589068,"src\/Fields\/Text.php":3296465271,"src\/Fields\/Image.php":4032533664,"src\/Fields\/Fields.php":3572158689,"src\/Fields\/Boolean.php":710075004,"src\/Fields\/Tab.php":3137926331,"src\/Fields\/Tabs.php":3422655071,"src\/Fields\/Select.php":2269241859,"src\/Headers\/Number.php":3468185039,"src\/Headers\/Text.php":3453491020,"src\/Headers\/Link.php":3708658392,"src\/Headers\/Money.php":1414716803,"src\/Headers\/Boolean.php":1436861502,"src\/Headers\/Date.php":791925921,"src\/Headers\/Label.php":2559479232,"src\/Headers\/Download.php":1670883268,"src\/Headers\/Headers.php":1828549759,"src\/Headers\/InertiaLink.php":3847878985,"src\/Headers\/Rating.php":2195370648,"src\/Headers\/Trend.php":3244001513,"src\/Headers\/Set.php":4116951602,"src\/Components\/Components.php":3025943152,"tests\/Pest.php":1399058707,"tests\/TestCase.php":51090682}}
3 changes: 2 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ includes:
- ./vendor/nunomaduro/larastan/extension.neon

parameters:
level: 5
level: 9
paths:
- src
tmpDir: build/phpstan
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
1 change: 1 addition & 0 deletions src/Commands/CreateCustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CreateCustomField extends Command
public function handle(): int
{
$name = $this->argument('name');
$name = is_string($name) ? $name : '';

if (! CreateCustomService::isNameValid($name)) {
$this->error("Name: '$name' is not valid");
Expand Down
1 change: 1 addition & 0 deletions src/Commands/CreateCustomFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CreateCustomFilter extends Command
public function handle(): int
{
$name = $this->argument('name');
$name = is_string($name) ? $name : '';

if (! CreateCustomService::isNameValid($name)) {
$this->error("Name: '$name' is not valid");
Expand Down
1 change: 1 addition & 0 deletions src/Commands/CreateCustomHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CreateCustomHeader extends Command
public function handle(): int
{
$name = $this->argument('name');
$name = is_string($name) ? $name : '';

if (! CreateCustomService::isNameValid($name)) {
$this->error("Name: '$name' is not valid");
Expand Down
11 changes: 7 additions & 4 deletions src/Components/Components.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@

final class Components
{
/**
* @var Collection<int, Component>
*/
private Collection $components;

public function __construct()
{
$this->components = new Collection();
}

public static function add(...$components)
public static function add(Component ...$components): self
{
$class = new self();

Expand All @@ -27,7 +30,7 @@ public static function add(...$components)
return $class;
}

public function push(Component $component)
public function push(Component $component): self
{
$this->components->push($component);

Expand All @@ -39,14 +42,14 @@ public function get(): Collection
return $this->components;
}

public function toArray()
public function toArray(): array
{
return $this->components->map(function (Component $component) {
return $component->toArray();
})->toArray();
}

public function getOptions()
public function getOptions(): array
{
return [];
}
Expand Down
6 changes: 6 additions & 0 deletions src/Contracts/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@

abstract class Component
{
/**
* @return string
*/
abstract public function getVue();

/**
* @return array
*/
public function toArray()
{
return [
Expand Down
9 changes: 9 additions & 0 deletions src/Contracts/ComponentsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@

interface ComponentsInterface
{
/**
* @return mixed
*/
public function header();

/**
* @return mixed
*/
public function aboveForm();

/**
* @return mixed
*/
public function belowForm();
}
8 changes: 6 additions & 2 deletions src/Contracts/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

abstract class Field
{
/** @var string */
public $type = 'text';
public string $label = '';
public string $name = '';
Expand All @@ -15,6 +16,9 @@ abstract class Field
'mt-6',
],
];
/**
* @var mixed
*/
protected $options;

public string $vueComponent;
Expand All @@ -34,7 +38,7 @@ public function __construct(string $name, string $label)
* @param bool $overwrite
* @return Field
*/
public function addWrapperClass($class, $overwrite = false)
public function addWrapperClass(string $class, $overwrite = false): Field
{
return $this->addClass('wrapper', $class, $overwrite);
}
Expand Down Expand Up @@ -66,7 +70,7 @@ public function toArray()
];
}

private function addClass(string $element, $class, $overwrite = false)
private function addClass(string $element, string $class, bool $overwrite = false): Field
{
if ($overwrite) {
$this->classes[$element] = $class;
Expand Down
22 changes: 15 additions & 7 deletions src/Contracts/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(string $label, string $field)
$this->filterMethods = new Collection();
}

public function __call($name, $arguments)
public function __call(string $name, array $arguments): Filter
{
if (method_exists($this, $name)) {
return $this->{$name}(...$arguments);
Expand All @@ -38,33 +38,38 @@ public function __call($name, $arguments)
return $this;
}

public function setLabel(string $label)
public function setLabel(string $label): Filter
{
$this->label = $label;

return $this;
}

public function setField(string $field)
public function setField(string $field): Filter
{
$this->field = $field;

return $this;
}

public function setType(string $type)
public function setType(string $type): Filter
{
$this->type = $type;

return $this;
}

public function setOption(string $key, $value)
/**
* @param string $key
* @param mixed $value
* @return void
*/
public function setOption(string $key, $value): void
{
$this->options[$key] = $value;
}

public function toArray()
public function toArray(): array
{
return [
'label' => $this->label,
Expand Down Expand Up @@ -102,7 +107,7 @@ public function setOperator(string $operator): self
return $this;
}

public function apply(Builder $builder, $value)
public function apply(Builder $builder, mixed $value): Builder
{
return $builder->where($this->getField(), $this->getOperator(), $value);
}
Expand All @@ -115,6 +120,9 @@ public function getFilterMethods(): Collection
return $this->filterMethods;
}

/**
* @return mixed
*/
private function getValue()
{
return app('request')->input("filters.{$this->getField()}");
Expand Down
21 changes: 13 additions & 8 deletions src/Contracts/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

abstract class Header
{
protected $value;
protected string $value;
protected string $label;

protected string $type = 'property';

protected $options = [];
protected array $options = [];

protected bool $sortable = false;
protected bool $editable = false;
Expand All @@ -22,20 +22,25 @@ public function __construct(string $label, string $value)
$this->setValue($value);
}

protected function setLabel(string $label)
protected function setLabel(string $label): self
{
$this->label = $label;

return $this;
}

protected function setValue($value)
protected function setValue(string $value): self
{
$this->value = $value;

return $this;
}

/**
* @param string $key
* @param mixed $value
* @return $this
*/
protected function setOption(string $key, $value): self
{
$this->options[$key] = $value;
Expand All @@ -54,28 +59,28 @@ protected function setType(string $type): Header
* Available Options
*/

public function editable(bool $editable = false)
public function editable(bool $editable = false): self
{
$this->editable = $editable;

return $this;
}

public function sortable()
public function sortable(): self
{
$this->sortable = true;

return $this;
}

public function tooltip(string $tooltip)
public function tooltip(string $tooltip): self
{
$this->setOption('tooltip', $tooltip);

return $this;
}

public function toArray()
public function toArray(): array
{
return [
'type' => $this->type,
Expand Down
4 changes: 4 additions & 0 deletions src/Contracts/Invokables.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@

interface Invokables
{
/**
* @param Renderer $renderer
* @return mixed
*/
public function __invoke(Renderer $renderer);
}
Loading