Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 authored and github-actions[bot] committed Jun 5, 2024
1 parent bb50821 commit 6b5255f
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 128 deletions.
22 changes: 11 additions & 11 deletions src/Abstracts/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function handle(): int

$path = str_replace('\\', '/', $this->getDestinationFilePath());

if (!$this->laravel['files']->isDirectory($dir = dirname($path))) {
if (! $this->laravel['files']->isDirectory($dir = dirname($path))) {
$this->laravel['files']->makeDirectory($dir, 0777, true);
}

Expand Down Expand Up @@ -60,9 +60,9 @@ protected function getDestinationFilePath(): string
{
$config = GenerateConfigReader::read($this->type);

return config('api-crud.root_path', 'app') . '/'
. $config->getPath() . '/'
. $this->getFileName();
return config('api-crud.root_path', 'app').'/'
.$config->getPath().'/'
.$this->getFileName();
}

/**
Expand All @@ -72,7 +72,7 @@ protected function getFileName()
{
$type = Str::studly($this->type);

return str_replace($type, '', Str::studly($this->argument('name'))) . "{$type}.php";
return str_replace($type, '', Str::studly($this->argument('name')))."{$type}.php";
}

/**
Expand All @@ -94,9 +94,9 @@ public function getClassNamespace(?string $module = null): string

$namespace = config('api-crud.namespace');

$namespace .= '\\' . $this->getDefaultNamespace();
$namespace .= '\\'.$this->getDefaultNamespace();

$namespace .= '\\' . $extra;
$namespace .= '\\'.$extra;

$namespace = str_replace('/', '\\', $namespace);

Expand All @@ -114,23 +114,23 @@ public function getClass(): string
/**
* Get default namespace.
*
* @param null $type
* @param null $type
*
* @throws GeneratorException
*/
public function getDefaultNamespace($type = null): string
{
if (!$type) {
if (! $type) {
if (property_exists($this, 'type')) {
$type = $this->type;
}
}

if (!$type) {
if (! $type) {
throw new GeneratorException('Stub type argument or property is not configured.');
}

if (!config("api-crud.templates.{$type}")) {
if (! config("api-crud.templates.{$type}")) {
throw new InvalidArgumentException("Generator is missing [{$type}] config, check generators.php file.");
}

Expand Down
24 changes: 12 additions & 12 deletions src/Commands/ControllerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function getTemplateContents(): string
'MESSAGE_VARIABLE' => Str::title(Str::replace('-', ' ', Str::kebab($this->getResourceVariableName()))),
'RESOURCE_NAMESPACES' => '',
'REQUEST_NAMESPACES' => '',
'MODEL' => str_replace('/', '\\', $this->getDefaultNamespace('model') . '\\' . $this->option('model')),
'MODEL' => str_replace('/', '\\', $this->getDefaultNamespace('model').'\\'.$this->option('model')),
'STORE_REQUEST' => '',
'UPDATE_REQUEST' => '',
'INDEX_REQUEST' => '',
Expand Down Expand Up @@ -116,9 +116,9 @@ private function setRequestNamespaces(array &$replacements)
$namespaces = [];

foreach (['Store', 'Update', 'Index'] as $prefix) {
$path = $this->getModuleName() . '/'
. $this->getDefaultNamespace('request') . '/'
. dirname($this->option('model')) . '/' . $prefix . class_basename($this->option('model')) . 'Request';
$path = $this->getModuleName().'/'
.$this->getDefaultNamespace('request').'/'
.dirname($this->option('model')).'/'.$prefix.class_basename($this->option('model')).'Request';

$path = str_replace('/./', '/', $path);
match ($prefix) {
Expand All @@ -127,7 +127,7 @@ private function setRequestNamespaces(array &$replacements)
'Update' => $replacements['UPDATE_REQUEST'] = basename($path),
};

$namespaces[] = ('use ' . implode('\\', explode('/', $path)) . ';');
$namespaces[] = ('use '.implode('\\', explode('/', $path)).';');

}

Expand All @@ -142,11 +142,11 @@ private function setResourceNamespaces(array &$replacements)
$namespaces = [];

foreach (['Resource', 'Collection'] as $suffix) {
$path = $this->getModuleName() . '/'
. $this->getDefaultNamespace('resource') . '/'
. $this->option('model') . $suffix;
$path = $this->getModuleName().'/'
.$this->getDefaultNamespace('resource').'/'
.$this->option('model').$suffix;

$namespaces[] = ('use ' . implode('\\', explode('/', $path)) . ';');
$namespaces[] = ('use '.implode('\\', explode('/', $path)).';');

}

Expand All @@ -155,15 +155,15 @@ private function setResourceNamespaces(array &$replacements)

protected function getClassPath(string $prefix = '', string $suffix = 'Request')
{
$resourcePath = $this->argument('name') . $suffix;
$resourcePath = $this->argument('name').$suffix;

$dir = dirname($resourcePath);

$dir = ($dir == '.') ? '' : $dir . '/';
$dir = ($dir == '.') ? '' : $dir.'/';

$resource = basename($resourcePath);

return $dir . $prefix . $resource;
return $dir.$prefix.$resource;
}

/**
Expand Down
36 changes: 18 additions & 18 deletions src/Commands/CrudMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ public function handle()

private function createRequest()
{
if (!config('api-crud.templates.request.generate', true)) {
if (! config('api-crud.templates.request.generate', true)) {
return;
}
foreach (['Index', 'Store', 'Update'] as $prefix) {

$resourcePath = $this->getResourceName() . 'Request';
$resourcePath = $this->getResourceName().'Request';

$dir = dirname($resourcePath);

$dir = ($dir == '.') ? '' : $dir . '/';
$dir = ($dir == '.') ? '' : $dir.'/';

$resource = basename($resourcePath);

$options = [
'name' => $dir . $prefix . $resource,
'name' => $dir.$prefix.$resource,
'module' => $this->getModuleName(),
];

Expand All @@ -105,16 +105,16 @@ private function getResourceName()

private function createResource()
{
if (!config('api-crud.templates.resource.generate', true)) {
if (! config('api-crud.templates.resource.generate', true)) {
return;
}
$this->call('laraflow:make-resource', [
'name' => $this->getResourceName() . 'Resource',
'name' => $this->getResourceName().'Resource',
'module' => $this->getModuleName(),
]);

$this->call('laraflow:make-resource', [
'name' => $this->getResourceName() . 'Collection',
'name' => $this->getResourceName().'Collection',
'module' => $this->getModuleName(),
'--collection' => true,
]);
Expand All @@ -126,7 +126,7 @@ private function createResource()
private function createModel()
{

if (!config('api-crud.templates.model.generate', true)) {
if (! config('api-crud.templates.model.generate', true)) {
return;
}
$this->call('laraflow:make-model', [
Expand All @@ -138,12 +138,12 @@ private function createModel()

private function createController()
{
if (!config('api-crud.templates.controller.generate', true)) {
if (! config('api-crud.templates.controller.generate', true)) {
return;
}

$this->call('laraflow:make-controller', [
'name' => $this->getResourceName() . 'Controller',
'name' => $this->getResourceName().'Controller',
'--model' => $this->getResourceName(),
'module' => $this->getModuleName(),
'--crud' => true,
Expand All @@ -157,13 +157,13 @@ private function updateRouteFile()
{
$filePath = base_path(config('api-crud.route_path', 'routes/api.php'));

if (!file_exists($filePath)) {
if (! file_exists($filePath)) {
throw new InvalidArgumentException("Route file location doesn't exist");
}

$fileContent = file_get_contents($filePath);

if (!str_contains($fileContent, '//DO NOT REMOVE THIS LINE//')) {
if (! str_contains($fileContent, '//DO NOT REMOVE THIS LINE//')) {
throw new GeneratorException('Route file missing the CRUD Pointer comment.');
}

Expand All @@ -174,12 +174,12 @@ private function updateRouteFile()
$controller =
GeneratorPath::convertPathToNamespace(
'\\'
. $this->getModuleName()
. '\\'
. GenerateConfigReader::read('controller')->getNamespace()
. '\\'
. $this->getResourceName()
. 'Controller::class'
.$this->getModuleName()
.'\\'
.GenerateConfigReader::read('controller')->getNamespace()
.'\\'
.$this->getResourceName()
.'Controller::class'
);

$template = <<<HTML
Expand Down
6 changes: 3 additions & 3 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ private function configureRouteFile(): void
{
$routeFilePath = base_path(config('api-crud.route_path', 'routes/api.php'));

if (!is_file($routeFilePath)) {
if (! is_file($routeFilePath)) {
throw new InvalidArgumentException("Invalid API route file path: ({$routeFilePath}).");
}

if (!is_readable($routeFilePath)) {
if (! is_readable($routeFilePath)) {
throw new AccessDeniedException('Unable to read from route file.');
}

Expand All @@ -75,7 +75,7 @@ private function configureRouteFile(): void

$content .= "\n//DO NOT REMOVE THIS LINE//\n";

if (!is_writable($routeFilePath)) {
if (! is_writable($routeFilePath)) {
throw new CannotWriteFileException('Unable to write on route file.');
}

Expand Down
4 changes: 2 additions & 2 deletions src/Commands/MigrationMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ protected function getDestinationFilePath(): string
{
$config = GenerateConfigReader::read($this->type);

return $config->getPath() . '/' . $this->getFileName();
return $config->getPath().'/'.$this->getFileName();
}

protected function getFileName()
{
return date('Y_m_d_His_\c\r\e\a\t\e_') . Str::snake($this->argument('name')) . '_table.php';
return date('Y_m_d_His_\c\r\e\a\t\e_').Str::snake($this->argument('name')).'_table.php';
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Commands/ModelMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function getTemplateContents(): string
return (new Stub('/model.stub', [
'NAME' => $this->getModelName(),
'ROUTE_NAME' => Str::plural(Str::lower(Str::kebab($this->getModelName()))),
'JSON_NAME' => Str::lower(Str::snake($this->getModelName())) . '_data',
'JSON_NAME' => Str::lower(Str::snake($this->getModelName())).'_data',
'TABLE' => $this->getTableName(),
'FILLABLE' => $this->getFillable(),
'NAMESPACE' => $this->getClassNamespace($this->getModuleName()),
Expand All @@ -154,7 +154,7 @@ private function getFillable()
{
$fillable = $this->option('fillable');

if (!is_null($fillable)) {
if (! is_null($fillable)) {
$arrays = explode(',', $fillable);

return json_encode($arrays);
Expand All @@ -168,6 +168,6 @@ private function getFillable()
*/
protected function getFileName()
{
return Str::studly($this->argument('name')) . '.php';
return Str::studly($this->argument('name')).'.php';
}
}
2 changes: 1 addition & 1 deletion src/Commands/ResourceMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ protected function isCollection(): bool
*/
protected function getFileName()
{
return Str::studly($this->argument('name')) . '.php';
return Str::studly($this->argument('name')).'.php';
}
}
4 changes: 2 additions & 2 deletions src/Exceptions/RestoreOperationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class RestoreOperationException extends Exception
/**
* RestoreOperationException constructor.
*
* @param string $message
* @param int $code
* @param string $message
* @param int $code
*/
public function __construct($message = '', $code = 0, ?Throwable $previous = null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/StoreOperationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class StoreOperationException extends Exception
/**
* StoreOperationException constructor.
*
* @param string $message
* @param int $code
* @param string $message
* @param int $code
*/
public function __construct($message = '', $code = 0, ?Throwable $previous = null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/UpdateOperationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class UpdateOperationException extends Exception
/**
* UpdateOperationException constructor.
*
* @param string $message
* @param int $code
* @param string $message
* @param int $code
*/
public function __construct($message = '', $code = 0, ?Throwable $previous = null)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Generators/FileGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FileGenerator
/**
* The constructor.
*
* @param null $filesystem
* @param null $filesystem
*/
public function __construct($path, $contents, $filesystem = null)
{
Expand Down Expand Up @@ -81,7 +81,7 @@ public function withFileOverwrite(bool $overwrite): FileGenerator
public function generate()
{
$path = $this->getPath();
if (!$this->filesystem->exists($path)) {
if (! $this->filesystem->exists($path)) {
return $this->filesystem->put($path, $this->getContents());
}
if ($this->overwriteFile === true) {
Expand All @@ -104,7 +104,7 @@ public function getPath()
/**
* Set path.
*
* @param mixed $path
* @param mixed $path
* @return $this
*/
public function setPath($path)
Expand All @@ -127,7 +127,7 @@ public function getContents()
/**
* Set contents.
*
* @param mixed $contents
* @param mixed $contents
* @return $this
*/
public function setContents($contents)
Expand Down
Loading

0 comments on commit 6b5255f

Please sign in to comment.