Skip to content

Commit

Permalink
Merge pull request #2 from Xammie/add-interface-and-repository
Browse files Browse the repository at this point in the history
Add interface and repository make commands
  • Loading branch information
Xammie authored Feb 16, 2022
2 parents 664c954 + 28d11b9 commit ffe5db3
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ return [
'contract' => 'Contracts',
'dto' => 'Dtos',
'enum' => 'Enums',
'interface' => 'Interfaces',
'repository' => 'Repositories',
'service' => 'Services'
],
];
Expand All @@ -70,6 +72,8 @@ php artisan make:action CreateUserAction
php artisan make:enum OrderStatusEnum
php artisan make:service PaymentService
php artisan make:contract CreatesUserContract
php artisan make:interface OrderRepositoryInterface
php artisan make:repository OrderRepository
php artisan make:dto RestRequestObject
```

Expand Down
2 changes: 2 additions & 0 deletions config/make-commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
'contract' => 'Contracts',
'dto' => 'Dtos',
'enum' => 'Enums',
'interface' => 'Interfaces',
'repository' => 'Repositories',
'service' => 'Services'
],
];
21 changes: 21 additions & 0 deletions src/Commands/InterfaceMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Xammie\MakeCommands\Commands;

use Illuminate\Console\GeneratorCommand;

class InterfaceMakeCommand extends GeneratorCommand
{
use GeneratorTrait;

protected $name = 'make:interface';

protected $description = 'Create a new interface';

protected $type = 'Interface';

protected function stubName(): string
{
return 'interface';
}
}
21 changes: 21 additions & 0 deletions src/Commands/RepositoryMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Xammie\MakeCommands\Commands;

use Illuminate\Console\GeneratorCommand;

class RepositoryMakeCommand extends GeneratorCommand
{
use GeneratorTrait;

protected $name = 'make:repository';

protected $description = 'Create a new repository class';

protected $type = 'Repository';

protected function stubName(): string
{
return 'repository';
}
}
8 changes: 8 additions & 0 deletions src/Commands/stubs/interface.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace {{ namespace }};

interface {{ class }}
{

}
8 changes: 8 additions & 0 deletions src/Commands/stubs/repository.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace {{ namespace }};

class {{ class }}
{

}
4 changes: 4 additions & 0 deletions src/MakeCommandsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Xammie\MakeCommands\Commands\ContractMakeCommand;
use Xammie\MakeCommands\Commands\DtoMakeCommand;
use Xammie\MakeCommands\Commands\EnumMakeCommand;
use Xammie\MakeCommands\Commands\InterfaceMakeCommand;
use Xammie\MakeCommands\Commands\RepositoryMakeCommand;
use Xammie\MakeCommands\Commands\ServiceMakeCommand;

class MakeCommandsServiceProvider extends PackageServiceProvider
Expand All @@ -27,6 +29,8 @@ public function configurePackage(Package $package): void
ContractMakeCommand::class,
DtoMakeCommand::class,
EnumMakeCommand::class,
InterfaceMakeCommand::class,
RepositoryMakeCommand::class,
ServiceMakeCommand::class,
]);
}
Expand Down
10 changes: 10 additions & 0 deletions tests/CommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Xammie\MakeCommands\Commands\ContractMakeCommand;
use Xammie\MakeCommands\Commands\DtoMakeCommand;
use Xammie\MakeCommands\Commands\EnumMakeCommand;
use Xammie\MakeCommands\Commands\InterfaceMakeCommand;
use Xammie\MakeCommands\Commands\RepositoryMakeCommand;
use Xammie\MakeCommands\Commands\ServiceMakeCommand;

it('can make action', function () {
Expand All @@ -23,6 +25,14 @@
artisan(EnumMakeCommand::class, ['name' => 'TestEnum'])->assertExitCode(0);
});

it('can make interface', function () {
artisan(InterfaceMakeCommand::class, ['name' => 'TestInterface'])->assertExitCode(0);
});

it('can make repository', function () {
artisan(RepositoryMakeCommand::class, ['name' => 'TestRepository'])->assertExitCode(0);
});

it('can make service', function () {
artisan(ServiceMakeCommand::class, ['name' => 'TestService'])->assertExitCode(0);
});

0 comments on commit ffe5db3

Please sign in to comment.