Skip to content

Commit

Permalink
(chore): format and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
FreakyWizard committed Nov 15, 2024
1 parent d990c13 commit 1bd3018
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
16 changes: 9 additions & 7 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ public static function create(Finder $finder, string $name = 'default'): self
{
$config = new self($name);

$config->setFinder($finder)->setDefaultSettings();
$config->setFinder($finder);
$config->setDefaultSettings();

return $config;
}

public function setDefaultSettings(): self {
public function setDefaultSettings(): self
{

$this->setRules($this->configRule('rules', []))
->setLineEnding($this->configRule('line_ending', "\n"))
->setRiskyAllowed($this->configRule('risky_allowed', true));
$this->setRules($this->configRule('rules', []))
->setLineEnding($this->configRule('line_ending', "\n"))
->setRiskyAllowed($this->configRule('risky_allowed', true));

return $this;
}
return $this;
}

public function mergeRules(array $rules): self
{
Expand Down
18 changes: 9 additions & 9 deletions src/Traits/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public function config(string $configFile, string $key, mixed $default = null):
return $config[$key] ?? $default;
}

/**
* Get specified rule from configuration.
*
* @param string $key key of config array
*/
public function configRule(string $key, mixed $default = null): mixed
{
return $this->config('settings', $key, $default);
}
/**
* Get specified rule from configuration.
*
* @param string $key key of config array
*/
public function configRule(string $key, mixed $default = null): mixed
{
return $this->config('settings', $key, $default);
}
}
22 changes: 11 additions & 11 deletions tests/Feature/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@
});

it('can reset to default settings', function () {
$config = Config::create(Finder::create());
$config = Config::create(Finder::create());

$defaultRules = $config->getRules();
$defaultLineEnding = $config->getLineEnding();
$defaultRiskyAllowed = $config->getRiskyAllowed();
$defaultRules = $config->getRules();
$defaultLineEnding = $config->getLineEnding();
$defaultRiskyAllowed = $config->getRiskyAllowed();

$config->setRules([])
->setLineEnding("\t\n")
->setRiskyAllowed(false);
$config->setRules([])
->setLineEnding("\t\n")
->setRiskyAllowed(false);

$config->setDefaultSettings();
$config->setDefaultSettings();

expect($config->getRules())->toBe($defaultRules);
expect($config->getLineEnding())->toBe($defaultLineEnding);
expect($config->getRiskyAllowed())->toBe($defaultRiskyAllowed);
expect($config->getRules())->toBe($defaultRules);
expect($config->getLineEnding())->toBe($defaultLineEnding);
expect($config->getRiskyAllowed())->toBe($defaultRiskyAllowed);
});

it('can override all rules', function () {
Expand Down

0 comments on commit 1bd3018

Please sign in to comment.