Skip to content

Commit

Permalink
[TASK] Add webomzart/assert to validate certain options
Browse files Browse the repository at this point in the history
  • Loading branch information
sabbelasichon committed Apr 17, 2024
1 parent 7467652 commit 3e77107
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion fractor/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"symfony/console": "^6.4",
"symfony/dependency-injection": "^6.4",
"symfony/filesystem": "^6.4",
"symfony/finder": "^6.4"
"symfony/finder": "^6.4",
"webmozart/assert": "^1.11"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.42",
Expand Down
2 changes: 1 addition & 1 deletion fractor/config/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

return static function (ContainerConfigurator $containerConfigurator, ContainerBuilder $containerBuilder): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, []);
$parameters->set(Option::PATHS, [__DIR__]);
$services = $containerConfigurator->services();
$services->defaults()
->autowire()
Expand Down
4 changes: 0 additions & 4 deletions fractor/src/Fractor/FractorRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ public function __construct(private FileFinder $fileFinder, private FileCollecto

public function run(Output $output, bool $dryRun = false): void
{
if ($this->configuration->getPaths() === []) {
throw new \RuntimeException('No directories given');
}

$files = $this->fileFinder->findFiles($this->configuration->getPaths(), $this->configuration->getFileExtensions());

$output->progressStart(count($files));
Expand Down
4 changes: 4 additions & 0 deletions fractor/src/ValueObject/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace a9f\Fractor\ValueObject;

use Webmozart\Assert\Assert;

final readonly class Configuration
{
/**
Expand All @@ -12,6 +14,8 @@
*/
public function __construct(private array $fileExtensions, private array $paths)
{
Assert::notEmpty($this->paths, 'No directories given');
Assert::allStringNotEmpty($this->paths, 'No directories given');
}

/**
Expand Down

0 comments on commit 3e77107

Please sign in to comment.