• 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

83.33
/src/Tempest/Database/src/Commands/MakeModelCommand.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Database\Commands;
6

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

15
final class MakeModelCommand
16
{
17
    use PublishesFiles;
18

19
    #[ConsoleCommand(
3✔
20
        name: 'make:model',
21
        description: 'Creates a new model class',
22
        aliases: ['model:make', 'model:create', 'create:model'],
23
    )]
24
    public function __invoke(
25
        #[ConsoleArgument(
26
            help: 'The name of the model class to create',
27
        )]
28
        string $className,
29
    ): void {
30
        $suggestedPath = $this->getSuggestedPath($className);
3✔
31
        $targetPath = $this->promptTargetPath($suggestedPath);
3✔
32
        $shouldOverride = $this->askForOverride($targetPath);
3✔
33

34
        try {
35

36
            $this->stubFileGenerator->generateClassFile(
3✔
37
                stubFile: StubFile::from(DatabaseModelStub::class),
3✔
38
                targetPath: $targetPath,
3✔
39
                shouldOverride: $shouldOverride,
3✔
40
            );
3✔
41

42
            $this->console->success(sprintf('File successfully created at "%s".', $targetPath));
3✔
NEW
43
        } catch (FileGenerationAbortedException|FileGenerationFailedException $e) {
×
NEW
44
            $this->console->error($e->getMessage());
×
45
        }
46
    }
47
}
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