Skip to content

Commit cb6dd9d

Browse files
committed
Introduces a configuration layer
1 parent 162a561 commit cb6dd9d

6 files changed

Lines changed: 126 additions & 0 deletions

File tree

src/Configuration/Creation.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Stolt\LeanPackage\Configuration;
4+
5+
final readonly class Creation
6+
{
7+
public function __construct(
8+
public string $directory,
9+
public bool $forceOverwrite,
10+
public string $flavour,
11+
public bool $dryRun,
12+
public bool $agenticRun,
13+
) {
14+
}
15+
}

src/Configuration/ExportIgnore.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Stolt\LeanPackage\Configuration;
4+
5+
final class ExportIgnore
6+
{
7+
8+
}

src/Configuration/Factory.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Stolt\LeanPackage\Configuration;
6+
7+
use Laravel\AgentDetector\AgentDetector;
8+
use Symfony\Component\Console\Input\InputInterface;
9+
10+
final class Factory
11+
{
12+
public function createValidationConfig(
13+
InputInterface $input
14+
): Validation {
15+
return new Validation(
16+
(string) $input->getArgument('directory'),
17+
(bool) $input->getOption('dry-run'),
18+
AgentDetector::detect()->isAgent === true,
19+
);
20+
}
21+
22+
public function createCreationConfig(
23+
InputInterface $input
24+
): Creation {
25+
return new Creation(
26+
(string) $input->getArgument('directory'),
27+
(bool) $input->getOption('force'),
28+
(string) $input->getOption('flavour'),
29+
(bool) $input->getOption('dry-run'),
30+
AgentDetector::detect()->isAgent === true,
31+
);
32+
}
33+
34+
public function createReformattingConfig(
35+
InputInterface $input
36+
): Reformatting {
37+
return new Reformatting(
38+
(string) $input->getArgument('directory'),
39+
(bool) $input->getOption('sort-alphabetically'),
40+
(bool) $input->getOption('sort-from-directories-to-files'),
41+
(bool) $input->getOption('group'),
42+
(bool) $input->getOption('dry-run'),
43+
AgentDetector::detect()->isAgent === true,
44+
);
45+
}
46+
47+
public function createUpdatingConfig(InputInterface $input
48+
): Updating {
49+
return new Updating(
50+
(string) $input->getArgument('directory'),
51+
(bool) $input->getOption('reformat-export-ignores'),
52+
(bool) $input->getOption('migrate-to-negated-export-ignores'),
53+
(bool) $input->getOption('group'),
54+
(bool) $input->getOption('dry-run'),
55+
AgentDetector::detect()->isAgent === true,
56+
);
57+
}
58+
}

src/Configuration/Reformatting.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Stolt\LeanPackage\Configuration;
4+
5+
final readonly class Reformatting
6+
{
7+
public function __construct(
8+
public string $directory,
9+
public bool $sortAlphabetically,
10+
public bool $sortFromDirectoriesToFiles,
11+
public bool $groupContent,
12+
public bool $dryRun,
13+
public bool $agenticRun,
14+
) {
15+
}
16+
}

src/Configuration/Updating.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Stolt\LeanPackage\Configuration;
4+
5+
final readonly class Updating
6+
{
7+
public function __construct(
8+
public string $directory,
9+
public bool $reformatExportIgnores,
10+
public bool $migrateToNegatedExportIgnores,
11+
public bool $group,
12+
public bool $dryRun,
13+
public bool $agenticRun,
14+
) {
15+
}
16+
}

src/Configuration/Validation.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Stolt\LeanPackage\Configuration;
4+
5+
final readonly class Validation
6+
{
7+
public function __construct(
8+
public string $directory,
9+
public bool $dryRun,
10+
public bool $agenticRun,
11+
) {
12+
}
13+
}

0 commit comments

Comments
 (0)