Skip to content

Commit

Permalink
Move initDefaultConfig to the init method (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
msmakouz authored Feb 23, 2023
1 parent e1b0601 commit 3bf2102
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/Bootloader/ValidatorBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,36 @@ public function __construct(
) {
}

public function boot(
ValidationProvider $provider,
TokenizerBootloader $tokenizer,
ValidationBootloader $validation
): void {
public function init(TokenizerBootloader $tokenizer): void
{
$this->initDefaultConfig($tokenizer);
}

public function boot(ValidationProvider $provider, ValidationBootloader $validation): void
{
$provider->register(
FilterDefinition::class,
static fn(Validation $validation): ValidationInterface => $validation
);
$validation->setDefaultValidator(FilterDefinition::class);
}

$this->initDefaultConfig($tokenizer);
public function addChecker(string $alias, mixed $checker): void
{
$this->config->modify(ValidatorConfig::CONFIG, new Append('checkers', $alias, $checker));
}

public function initDefaultConfig(TokenizerBootloader $tokenizer): void
public function addCondition(string $alias, mixed $condition): void
{
$this->config->modify(ValidatorConfig::CONFIG, new Append('conditions', $alias, $condition));
}

public function addAlias(string $alias, string $target): void
{
$this->config->modify(ValidatorConfig::CONFIG, new Append('aliases', $alias, $target));
}

private function initDefaultConfig(TokenizerBootloader $tokenizer): void
{
$this->config->setDefaults(
ValidatorConfig::CONFIG,
Expand Down Expand Up @@ -122,19 +137,4 @@ public function initDefaultConfig(TokenizerBootloader $tokenizer): void
->getFileName()
));
}

public function addChecker(string $alias, mixed $checker): void
{
$this->config->modify(ValidatorConfig::CONFIG, new Append('checkers', $alias, $checker));
}

public function addCondition(string $alias, mixed $condition): void
{
$this->config->modify(ValidatorConfig::CONFIG, new Append('conditions', $alias, $condition));
}

public function addAlias(string $alias, string $target): void
{
$this->config->modify(ValidatorConfig::CONFIG, new Append('aliases', $alias, $target));
}
}

0 comments on commit 3bf2102

Please sign in to comment.