Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit db79395

Browse files
committed
refactoring
1 parent e2c5d6f commit db79395

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/Traits/HelpsLoopFunctions.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,9 @@ private function assignValue(int|string $key, mixed $value, mixed $rescue = null
2929
/**
3030
* @return array
3131
*/
32-
private function ignoreKeys(): array
32+
private function ignoredPropertyNames(): array
3333
{
34-
$defaults = ['id', 'password'];
35-
36-
$ignores = config('loop-functions.ignore_keys', $defaults);
37-
38-
return is_array($ignores)
39-
? $ignores
40-
: $defaults;
34+
return config('loop-functions.ignore_keys', ['id', 'password']);
4135
}
4236

4337
/**

src/Traits/LoopFunctions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function propertiesFrom(Model|array|null $data = null, mixed $rescue = nu
3939
public function attributesToProperties(?Model $model = null, mixed $rescue = null): void
4040
{
4141
collect($model?->getAttributes())
42-
->except($this->ignoreKeys())
42+
->except($this->ignoredPropertyNames())
4343
->each(
4444
fn ($value, $property) => $this->assignValue(
4545
$property,
@@ -60,7 +60,7 @@ public function attributesToProperties(?Model $model = null, mixed $rescue = nul
6060
public function arrayToProperties(?array $data, mixed $rescue = null): void
6161
{
6262
collect($data ?? [])
63-
->except($this->ignoreKeys())
63+
->except($this->ignoredPropertyNames())
6464
->each(fn ($value, $key) => $this->assignValue($key, $value, $rescue));
6565
}
6666
}

0 commit comments

Comments
 (0)