Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspertey committed Mar 24, 2024
1 parent 191fa99 commit 90e41f5
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 36 deletions.
3 changes: 2 additions & 1 deletion src/Commands/Concerns/ResolvesDomainFromInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Lunarstorm\LaravelDDD\Support\DomainResolver;
use Lunarstorm\LaravelDDD\Support\Path;
use Symfony\Component\Console\Input\InputOption;

use function Laravel\Prompts\text;

trait ResolvesDomainFromInput
Expand Down Expand Up @@ -81,7 +82,7 @@ public function handle()
};

// If the domain is not set, prompt for it
if (!$this->domain) {
if (! $this->domain) {
$this->domain = new Domain(text(
label: 'What is the domain?',
required: true,
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function registerDomainAutoload()

$composerFile = base_path('composer.json');
$data = json_decode(file_get_contents($composerFile), true);
data_fill($data, ['autoload', 'psr-4', $domainRootNamespace . '\\'], $domainPath);
data_fill($data, ['autoload', 'psr-4', $domainRootNamespace.'\\'], $domainPath);

file_put_contents($composerFile, json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));

Expand Down
1 change: 0 additions & 1 deletion src/Commands/MakeBaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Lunarstorm\LaravelDDD\Commands;

use Lunarstorm\LaravelDDD\Commands\Concerns\ResolvesDomainFromInput;
use Symfony\Component\Console\Input\InputArgument;

class MakeBaseModel extends DomainGeneratorCommand
Expand Down
1 change: 0 additions & 1 deletion src/Commands/MakeBaseViewModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Lunarstorm\LaravelDDD\Commands;

use Lunarstorm\LaravelDDD\Commands\Concerns\ResolvesDomainFromInput;
use Symfony\Component\Console\Input\InputArgument;

class MakeBaseViewModel extends DomainGeneratorCommand
Expand Down
2 changes: 0 additions & 2 deletions src/Commands/MakeDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Lunarstorm\LaravelDDD\Commands;

use Lunarstorm\LaravelDDD\Commands\Concerns\ResolvesDomainFromInput;

class MakeDTO extends DomainGeneratorCommand
{
protected $name = 'ddd:dto';
Expand Down
4 changes: 1 addition & 3 deletions src/Commands/MakeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Lunarstorm\LaravelDDD\Commands;

use Lunarstorm\LaravelDDD\Commands\Concerns\ResolvesDomainFromInput;
use Lunarstorm\LaravelDDD\Support\Domain;
use Lunarstorm\LaravelDDD\Support\Path;
use Symfony\Component\Console\Input\InputOption;

Expand Down Expand Up @@ -107,6 +105,6 @@ protected function guessModelName($name)
$name = substr($name, 0, -7);
}

return ($this->domain)->model($name)->name;
return $this->domain->model($name)->name;
}
}
3 changes: 1 addition & 2 deletions src/Commands/MakeModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Lunarstorm\LaravelDDD\Commands;

use Lunarstorm\LaravelDDD\Commands\Concerns\ResolvesDomainFromInput;
use Lunarstorm\LaravelDDD\Support\DomainResolver;
use Symfony\Component\Console\Input\InputOption;

Expand Down Expand Up @@ -96,7 +95,7 @@ protected function createBaseModelIfNeeded()
protected function createFactory()
{
$this->call(MakeFactory::class, [
'name' => $this->getNameInput() . 'Factory',
'name' => $this->getNameInput().'Factory',
'--domain' => $this->domain->dotName,
'--model' => $this->qualifyClass($this->getNameInput()),
]);
Expand Down
2 changes: 0 additions & 2 deletions src/Commands/MakeValueObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Lunarstorm\LaravelDDD\Commands;

use Lunarstorm\LaravelDDD\Commands\Concerns\ResolvesDomainFromInput;

class MakeValueObject extends DomainGeneratorCommand
{
protected $name = 'ddd:value';
Expand Down
4 changes: 2 additions & 2 deletions src/Factories/DomainFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function resolveFactoryName(string $modelName)
// Expected domain model FQN:
// {DomainNamespace}\{Domain}\{ModelNamespace}\{Model}

if (!Str::startsWith($modelName, $domainNamespace)) {
if (! Str::startsWith($modelName, $domainNamespace)) {
// Not a domain model
return null;
}
Expand All @@ -46,7 +46,7 @@ public static function resolveFactoryName(string $modelName)

$modelBaseName = class_basename($modelName);

return static::$namespace . "{$domain}\\{$modelBaseName}Factory";
return static::$namespace."{$domain}\\{$modelBaseName}Factory";
};

return $resolver($modelName);
Expand Down
6 changes: 3 additions & 3 deletions src/Support/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public function object(string $type, string $name): DomainObject
return new DomainObject(
name: $name,
namespace: $namespace,
fqn: $namespace . '\\' . $name,
path: $this->path($namespace . '\\' . $name),
fqn: $namespace.'\\'.$name,
path: $this->path($namespace.'\\'.$name),
);
}

Expand All @@ -123,7 +123,7 @@ public function factory(string $name): DomainObject
return new DomainObject(
name: $name,
namespace: $this->namespace->factories,
fqn: $this->namespace->factories . '\\' . $name,
fqn: $this->namespace->factories.'\\'.$name,
path: str("database/factories/{$this->domainWithSubdomain}/{$name}.php")
->replace(['\\', '/'], DIRECTORY_SEPARATOR)
->toString()
Expand Down
30 changes: 15 additions & 15 deletions src/ValueObjects/DomainNamespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ public static function from(string $domain, ?string $subdomain = null): self

return new self(
root: $domainNamespace,
models: "{$domainNamespace}\\" . config('ddd.namespaces.model', 'Models'),
models: "{$domainNamespace}\\".config('ddd.namespaces.model', 'Models'),
factories: "Database\\Factories\\{$domainWithSubdomain}",
dataTransferObjects: "{$domainNamespace}\\" . config('ddd.namespaces.data_transfer_object', 'Data'),
viewModels: "{$domainNamespace}\\" . config('ddd.namespaces.view_model', 'ViewModels'),
valueObjects: "{$domainNamespace}\\" . config('ddd.namespaces.value_object', 'ValueObjects'),
actions: "{$domainNamespace}\\" . config('ddd.namespaces.action', 'Actions'),
enums: "{$domainNamespace}\\" . config('ddd.namespaces.enums', 'Enums'),
events: "{$domainNamespace}\\" . config('ddd.namespaces.event', 'Events'),
casts: "{$domainNamespace}\\" . config('ddd.namespaces.cast', 'Casts'),
commands: "{$domainNamespace}\\" . config('ddd.namespaces.command', 'Commands'),
exceptions: "{$domainNamespace}\\" . config('ddd.namespaces.exception', 'Exceptions'),
jobs: "{$domainNamespace}\\" . config('ddd.namespaces.job', 'Jobs'),
mail: "{$domainNamespace}\\" . config('ddd.namespaces.mail', 'Mail'),
notifications: "{$domainNamespace}\\" . config('ddd.namespaces.notification', 'Notifications'),
resources: "{$domainNamespace}\\" . config('ddd.namespaces.resource', 'Resources'),
rules: "{$domainNamespace}\\" . config('ddd.namespaces.rule', 'Rules'),
dataTransferObjects: "{$domainNamespace}\\".config('ddd.namespaces.data_transfer_object', 'Data'),
viewModels: "{$domainNamespace}\\".config('ddd.namespaces.view_model', 'ViewModels'),
valueObjects: "{$domainNamespace}\\".config('ddd.namespaces.value_object', 'ValueObjects'),
actions: "{$domainNamespace}\\".config('ddd.namespaces.action', 'Actions'),
enums: "{$domainNamespace}\\".config('ddd.namespaces.enums', 'Enums'),
events: "{$domainNamespace}\\".config('ddd.namespaces.event', 'Events'),
casts: "{$domainNamespace}\\".config('ddd.namespaces.cast', 'Casts'),
commands: "{$domainNamespace}\\".config('ddd.namespaces.command', 'Commands'),
exceptions: "{$domainNamespace}\\".config('ddd.namespaces.exception', 'Exceptions'),
jobs: "{$domainNamespace}\\".config('ddd.namespaces.job', 'Jobs'),
mail: "{$domainNamespace}\\".config('ddd.namespaces.mail', 'Mail'),
notifications: "{$domainNamespace}\\".config('ddd.namespaces.notification', 'Notifications'),
resources: "{$domainNamespace}\\".config('ddd.namespaces.resource', 'Resources'),
rules: "{$domainNamespace}\\".config('ddd.namespaces.rule', 'Rules'),
);
}
}
2 changes: 1 addition & 1 deletion src/ValueObjects/DomainObjectNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function make(string $key, string $domain, ?string $subdomain = nu

$domainNamespace = implode('\\', [$root, $domainWithSubdomain]);

$namespace = "{$domainNamespace}\\" . config("ddd.namespaces.{$key}", Str::studly($key));
$namespace = "{$domainNamespace}\\".config("ddd.namespaces.{$key}", Str::studly($key));

return new self(key: $key, namespace: $namespace);
}
Expand Down
1 change: 0 additions & 1 deletion tests/Generator/MakeModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Str;
use Lunarstorm\LaravelDDD\Support\Domain;
use Lunarstorm\LaravelDDD\Tests\Fixtures\Enums\Feature;

Expand Down
1 change: 0 additions & 1 deletion tests/Generator/PromptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
->assertExitCode(0);
});


it('[value object] prompts for missing input', function () {
$this->artisan('ddd:value')
->expectsQuestion('What should the value object be named?', 'Belt')
Expand Down

0 comments on commit 90e41f5

Please sign in to comment.