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

tempestphp / tempest-framework / 11800557345

12 Nov 2024 03:33PM UTC coverage: 82.436% (-0.02%) from 82.455%
11800557345

Pull #647

github

web-flow
Merge b39c42cf3 into d599d5047
Pull Request #647: feat(console): add `make:controller` and `make:model` commands

175 of 213 new or added lines in 12 files covered. (82.16%)

19 existing lines in 2 files now uncovered.

7425 of 9007 relevant lines covered (82.44%)

51.71 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
            help: 'The path of the route',
31
        )]
32
        ?string $controllerPath = null,
33
        #[ConsoleArgument(
34
            help: 'The name of the view returned from the controller',
35
        )]
36
        ?string $controllerView = null,
37
    ): void {
38
        $suggestedPath = $this->getSuggestedPath($className);
3✔
39
        $targetPath = $this->promptTargetPath($suggestedPath);
3✔
40
        $shouldOverride = $this->askForOverride($targetPath);
3✔
41

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

53
            $this->success(sprintf('File successfully created at "%s".', $targetPath));
3✔
NEW
54
        } catch (FileGenerationAbortedException|FileGenerationFailedException $e) {
×
NEW
55
            $this->error($e->getMessage());
×
56
        }
57
    }
58
}
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