• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tempestphp / tempest-framework / 12001276346

20 Nov 2024 12:29PM UTC coverage: 81.993%. Remained the same
12001276346

push

github

web-flow
refactor(console): update `make:controller` command parameters to be simpler (#761)

2 of 2 new or added lines in 2 files covered. (100.0%)

2 existing lines in 1 file now uncovered.

8032 of 9796 relevant lines covered (81.99%)

51.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/Tempest/Http/src/Commands/MakeControllerCommand.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Http\Commands;
6

7
use Tempest\Console\ConsoleArgument;
8
use Tempest\Console\ConsoleCommand;
9
use Tempest\Core\PublishesFiles;
10
use Tempest\Generation\DataObjects\StubFile;
11
use Tempest\Generation\Exceptions\FileGenerationAbortedException;
12
use Tempest\Generation\Exceptions\FileGenerationFailedException;
13
use Tempest\Http\Stubs\ControllerStub;
14

15
final class MakeControllerCommand
16
{
17
    use PublishesFiles;
18

19
    #[ConsoleCommand(
3✔
20
        name: 'make:controller',
21
        description: 'Creates a new controller class with a route',
22
        aliases: ['controller:make', 'controller:create', 'create:controller'],
23
    )]
24
    public function __invoke(
25
        #[ConsoleArgument(
26
            help: 'The name of the controller class to create',
27
        )]
28
        string $className,
29
        #[ConsoleArgument(
30
            name: 'path',
31
            help: 'The path of the route',
32
        )]
33
        ?string $controllerPath = null,
34
        #[ConsoleArgument(
35
            name: 'view',
36
            help: 'The name of the view returned from the controller',
37
        )]
38
        ?string $controllerView = null,
39
    ): void {
40
        $suggestedPath = $this->getSuggestedPath($className);
3✔
41
        $targetPath = $this->promptTargetPath($suggestedPath);
3✔
42
        $shouldOverride = $this->askForOverride($targetPath);
3✔
43

44
        try {
45
            $this->stubFileGenerator->generateClassFile(
3✔
46
                stubFile: StubFile::from(ControllerStub::class),
3✔
47
                targetPath: $targetPath,
3✔
48
                shouldOverride: $shouldOverride,
3✔
49
                replacements: [
3✔
50
                    'dummy-path' => $controllerPath,
3✔
51
                    'dummy-view' => $controllerView,
3✔
52
                ],
3✔
53
            );
3✔
54

55
            $this->success(sprintf('Controller successfully created at "%s".', $targetPath));
3✔
UNCOV
56
        } catch (FileGenerationAbortedException|FileGenerationFailedException $e) {
×
UNCOV
57
            $this->error($e->getMessage());
×
58
        }
59
    }
60
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc