Skip to content

Commit 3bdf40c

Browse files
authored
Update: Change log_reference_length to log_reference_params (#34)
Update: Change log_reference_length to log_reference_params to allow passing additional parameters to the log reference generator
1 parent 1696296 commit 3bdf40c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

config/pay-pocket.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
| This configuration allows you to customize the generation of log reference strings
1313
| within the LaravelPayPocket package.
1414
|
15-
| - log_reference_length: The length of the generated reference string.
16-
| - log_reference_prefix: The prefix for the generated reference string.
17-
| - log_reference_generator_class: The fully qualified name of the class containing static methods for generation.
18-
| - log_reference_generator_method: The name of the static method available in the generator class.
15+
| - [array] log_reference_params: The parameters to pass to the log reference generator.
16+
| - [string] log_reference_prefix: The prefix for the generated reference string.
17+
| - [class-string] log_reference_generator_class: The fully qualified name of the class containing static methods for generation.
18+
| - [string] log_reference_generator_method: The name of the static method available in the generator class.
1919
|
2020
| This is how it works by default in the code:
2121
| Illuminate\Support\Str::random(12)
2222
|
2323
*/
2424

25-
'log_reference_length' => 12,
25+
'log_reference_params' => [12],
2626
'log_reference_prefix' => '',
2727
'log_reference_generator_class' => Illuminate\Support\Str::class,
2828
'log_reference_generator_method' => 'random',

src/Traits/BalanceOperation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ protected function generateReference(): string
6565
{
6666
$className = config('pay-pocket.log_reference_generator_class');
6767
$methodName = config('pay-pocket.log_reference_generator_method');
68-
$length = config('pay-pocket.log_reference_length');
68+
$params = (array)config('pay-pocket.log_reference_params', [12]);
6969
$prefix = config('pay-pocket.log_reference_prefix');
7070

7171
if (! is_callable([$className, $methodName])) {
7272
throw new InvalidArgumentException('Invalid configuration: The combination of log_reference_generator_class and log_reference_generator_method is not callable.');
7373
}
7474

75-
$reference = call_user_func([$className, $methodName], $length);
75+
$reference = call_user_func([$className, $methodName], ...$params);
7676

77-
return $prefix.$reference;
77+
return $prefix . $reference;
7878
}
7979
}

0 commit comments

Comments
 (0)