Skip to content

Commit 694e74a

Browse files
fix: files formatting
1 parent a8ef450 commit 694e74a

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

packages/validation/src/Rules/Custom.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44

55
namespace Tempest\Validation\Rules;
66

7-
use Closure;
87
use Attribute;
8+
use Closure;
99
use InvalidArgumentException;
1010
use ReflectionFunction;
1111
use Tempest\Validation\Rule;
1212

13-
1413
/**
1514
* Custom validation rule defined by a closure.
1615
*
@@ -19,7 +18,6 @@
1918
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
2019
final readonly class Custom implements Rule
2120
{
22-
2321
private Closure $callback;
2422

2523
public function __construct(
@@ -30,7 +28,7 @@ public function __construct(
3028
$reflection = new ReflectionFunction($callback);
3129

3230
// Must be static
33-
if (!$reflection->isStatic()) {
31+
if (! $reflection->isStatic()) {
3432
throw new InvalidArgumentException('Validation closures must be static');
3533
}
3634

packages/validation/tests/Rules/CustomTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,22 @@ final class CustomTest 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, '@'));
18-
17+
$rule = new Custom(static fn (mixed $value): bool => str_contains((string) $value, '@'));
1918
$this->assertTrue($rule->isValid('[email protected]'));
2019
$this->assertTrue($rule->isValid('[email protected]'));
2120
}
2221

2322
public function test_closure_validation_fails(): void
2423
{
25-
$rule = new Custom(static fn(mixed $value): bool => str_contains((string) $value, '@'));
24+
$rule = new Custom(static fn (mixed $value): bool => str_contains((string) $value, '@'));
2625

2726
$this->assertFalse($rule->isValid('username'));
2827
$this->assertFalse($rule->isValid('example.com'));
2928
}
3029

3130
public function test_non_string_value_fails(): void
3231
{
33-
$rule = new Custom(static fn(mixed $value): bool => str_contains((string) $value, '@'));
32+
$rule = new Custom(static fn (mixed $value): bool => str_contains((string) $value, '@'));
3433

3534
$this->assertFalse($rule->isValid(12345));
3635
$this->assertFalse($rule->isValid(null));
@@ -41,7 +40,6 @@ public function test_static_closure_required(): void
4140
{
4241
$this->expectException(\InvalidArgumentException::class);
4342

44-
// Non-static closure should throw exception
45-
new Custom(fn(mixed $value): bool => str_contains((string) $value, '@'));
43+
new Custom(fn (mixed $value): bool => str_contains((string) $value, '@'));
4644
}
4745
}

0 commit comments

Comments
 (0)