Skip to content

Commit 30d35bd

Browse files
fix: more descriptive class name
1 parent 694e74a commit 30d35bd

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Tempest\Validation\Rules;
66

77
use Attribute;
8-
use Closure;
98
use InvalidArgumentException;
109
use ReflectionFunction;
1110
use Tempest\Validation\Rule;
@@ -16,12 +15,12 @@
1615
* The closure receives the value and must return true if it is valid, false otherwise.
1716
*/
1817
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
19-
final readonly class Custom implements Rule
18+
final readonly class Closure implements Rule
2019
{
21-
private Closure $callback;
20+
private \Closure $callback;
2221

2322
public function __construct(
24-
Closure $callback,
23+
\Closure $callback,
2524
) {
2625
$this->callback = $callback;
2726

packages/validation/tests/Rules/CustomTest.php renamed to packages/validation/tests/Rules/ClosureTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55
namespace Tempest\Validation\Tests\Rules;
66

77
use PHPUnit\Framework\TestCase;
8-
use Tempest\Validation\Rules\Custom;
8+
use Tempest\Validation\Rules\Closure;
99

1010
/**
1111
* @internal
1212
*/
13-
final class CustomTest extends TestCase
13+
final class ClosureTest extends TestCase
1414
{
1515
public function test_closure_validation_passes(): void
1616
{
17-
$rule = new Custom(static fn (mixed $value): bool => str_contains((string) $value, '@'));
17+
$rule = new Closure(static fn (mixed $value): bool => str_contains((string) $value, '@'));
1818
$this->assertTrue($rule->isValid('[email protected]'));
1919
$this->assertTrue($rule->isValid('[email protected]'));
2020
}
2121

2222
public function test_closure_validation_fails(): void
2323
{
24-
$rule = new Custom(static fn (mixed $value): bool => str_contains((string) $value, '@'));
24+
$rule = new Closure(static fn (mixed $value): bool => str_contains((string) $value, '@'));
2525

2626
$this->assertFalse($rule->isValid('username'));
2727
$this->assertFalse($rule->isValid('example.com'));
2828
}
2929

3030
public function test_non_string_value_fails(): void
3131
{
32-
$rule = new Custom(static fn (mixed $value): bool => str_contains((string) $value, '@'));
32+
$rule = new Closure(static fn (mixed $value): bool => str_contains((string) $value, '@'));
3333

3434
$this->assertFalse($rule->isValid(12345));
3535
$this->assertFalse($rule->isValid(null));
@@ -40,6 +40,6 @@ public function test_static_closure_required(): void
4040
{
4141
$this->expectException(\InvalidArgumentException::class);
4242

43-
new Custom(fn (mixed $value): bool => str_contains((string) $value, '@'));
43+
new Closure(fn (mixed $value): bool => str_contains((string) $value, '@'));
4444
}
4545
}

0 commit comments

Comments
 (0)