Skip to content

Commit

Permalink
Merge pull request #1207: Apply Spiral Code Style
Browse files Browse the repository at this point in the history
  • Loading branch information
spiralbot committed Jan 24, 2025
1 parent 40f0a22 commit c87bcf1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 27 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
],
"require": {
"php": ">=8.1",
"spiral/core": "^3.14.10"
"spiral/core": "^3.15"
},
"require-dev": {
"spiral/boot": "^3.14.10",
"spiral/boot": "^3.15",
"phpunit/phpunit": "^10.1",
"mockery/mockery": "^1.5",
"vimeo/psalm": "^5.9"
Expand Down
7 changes: 3 additions & 4 deletions src/Bootloader/ValidationBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ final class ValidationBootloader extends Bootloader
];

public function __construct(
private readonly ConfiguratorInterface $config
) {
}
private readonly ConfiguratorInterface $config,
) {}

public function init(): void
{
Expand All @@ -46,7 +45,7 @@ public function setDefaultValidator(string $name): void

private function initDefaultValidator(
ValidationConfig $config,
ValidationProviderInterface $provider
ValidationProviderInterface $provider,
): ValidationInterface {
if ($config->getDefaultValidator() === null) {
throw new ValidationException('Default Validator is not configured.');
Expand Down
4 changes: 1 addition & 3 deletions src/Exception/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Spiral\Validation\Exception;

class ValidationException extends \RuntimeException
{
}
class ValidationException extends \RuntimeException {}
7 changes: 3 additions & 4 deletions src/ValidationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ final class ValidationProvider implements ValidationProviderInterface
private array $resolvers = [];

public function __construct(
private readonly InvokerInterface $invoker
) {
}
private readonly InvokerInterface $invoker,
) {}

/**
* @param non-empty-string $name
Expand All @@ -38,7 +37,7 @@ public function getValidation(string $name, array $params = []): ValidationInter

return $this->invoker->invoke(
$this->resolvers[$name],
$params
$params,
);
}
}
4 changes: 2 additions & 2 deletions tests/Config/ValidationConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public function testDefaultValidatorIsNotSet(): void
{
$config = new ValidationConfig();

$this->assertNull($config->getDefaultValidator());
self::assertNull($config->getDefaultValidator());
}

public function testDefaultValidator(): void
{
$config = new ValidationConfig(['defaultValidator' => 'some']);

$this->assertSame('some', $config->getDefaultValidator());
self::assertSame('some', $config->getDefaultValidator());
}
}
21 changes: 9 additions & 12 deletions tests/ValidationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ final class ValidationProviderTest extends TestCase
private m\MockInterface|InvokerInterface $invoker;
private ValidationProvider $provider;

protected function setUp(): void
{
parent::setUp();

$this->invoker = m::mock(InvokerInterface::class);
$this->provider = new ValidationProvider($this->invoker);
}

public function testRegisterValidator(): void
{
$validation = m::mock(ValidationInterface::class);
Expand All @@ -35,9 +27,14 @@ public function testRegisterValidator(): void
->with($resolver, $params)
->andReturn($validation);

$this->assertSame(
$validation,
$this->provider->getValidation('foo', $params)
);
self::assertSame($validation, $this->provider->getValidation('foo', $params));
}

protected function setUp(): void
{
parent::setUp();

$this->invoker = m::mock(InvokerInterface::class);
$this->provider = new ValidationProvider($this->invoker);
}
}

0 comments on commit c87bcf1

Please sign in to comment.