Skip to content

Commit 9392d12

Browse files
committed
feat: add candidate option to generator command
1 parent 3ecabd5 commit 9392d12

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/Commands/MakeSpecificationCommand.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,39 @@ protected function getDefaultNamespace($rootNamespace): string
2929
return sprintf('%s\Specifications', $rootNamespace);
3030
}
3131

32+
protected function buildClass($name): string
33+
{
34+
$replacements = [
35+
'{{ candidate }}' => $this->option('candidate'),
36+
];
37+
38+
return str_replace(
39+
array_keys($replacements),
40+
array_values($replacements),
41+
parent::buildClass($name),
42+
);
43+
}
44+
3245
protected function getOptions(): array
3346
{
3447
$composite = new InputOption(
3548
'composite',
36-
'c',
49+
null,
3750
InputOption::VALUE_NONE,
3851
'Indicates the specification should be composite',
3952
);
4053

54+
$candidate = new InputOption(
55+
'candidate',
56+
'c',
57+
InputOption::VALUE_OPTIONAL,
58+
'Specify the candidate type to use',
59+
'mixed',
60+
);
61+
4162
return [
4263
$composite,
64+
$candidate,
4365
];
4466
}
4567
}

stubs/specification-composite.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace {{ namespace }};
77
use Maartenpaauw\Specifications\CompositeSpecification;
88

99
/**
10-
* @extends CompositeSpecification<mixed>
10+
* @extends CompositeSpecification<{{ candidate }}>
1111
*/
1212
class {{ class }} extends CompositeSpecification
1313
{

stubs/specification.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace {{ namespace }};
77
use Maartenpaauw\Specifications\Specification;
88

99
/**
10-
* @implements Specification<mixed>
10+
* @implements Specification<{{ candidate }}>
1111
*/
1212
class {{ class }} implements Specification
1313
{

0 commit comments

Comments
 (0)