@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $bar = $this->output->createProgressBar($models->count()); |
| 63 | 63 | |
| 64 | - $models->transform(function ($model) use ($bar) { |
|
| 64 | + $models->transform(function($model) use ($bar) { |
|
| 65 | 65 | $bar->advance(); |
| 66 | 66 | return new GraphModel( |
| 67 | 67 | $model, |
@@ -85,8 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | protected function getOutputFileName(): string |
| 87 | 87 | { |
| 88 | - return $this->argument('filename') ?: |
|
| 89 | - static::DEFAULT_FILENAME . '.' . $this->option('format'); |
|
| 88 | + return $this->argument('filename') ?: static::DEFAULT_FILENAME . '.' . $this->option('format'); |
|
| 90 | 89 | } |
| 91 | 90 | |
| 92 | 91 | protected function getModelsThatShouldBeInspected(): Collection |
@@ -101,7 +100,7 @@ discard block |
||
| 101 | 100 | protected function getAllModelsFromEachDirectory(array $directories): Collection |
| 102 | 101 | { |
| 103 | 102 | return collect($directories) |
| 104 | - ->map(function ($directory) { |
|
| 103 | + ->map(function($directory) { |
|
| 105 | 104 | return $this->modelFinder->getModelsInDirectory($directory)->all(); |
| 106 | 105 | }) |
| 107 | 106 | ->flatten(); |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | { |
| 52 | 52 | $attributes = array(); |
| 53 | 53 | foreach ($this->attributes as $value) { |
| 54 | - $attributes[] = (string)$value; |
|
| 54 | + $attributes[ ] = (string)$value; |
|
| 55 | 55 | } |
| 56 | 56 | $attributes = implode("\n", $attributes); |
| 57 | 57 | |
@@ -24,25 +24,25 @@ |
||
| 24 | 24 | { |
| 25 | 25 | $class = new ReflectionClass($model); |
| 26 | 26 | |
| 27 | - $traitMethods = Collection::make($class->getTraits())->map(function (ReflectionClass $trait) { |
|
| 27 | + $traitMethods = Collection::make($class->getTraits())->map(function(ReflectionClass $trait) { |
|
| 28 | 28 | return Collection::make($trait->getMethods(ReflectionMethod::IS_PUBLIC)); |
| 29 | 29 | })->flatten(); |
| 30 | 30 | |
| 31 | 31 | $methods = Collection::make($class->getMethods(ReflectionMethod::IS_PUBLIC)) |
| 32 | 32 | ->merge($traitMethods) |
| 33 | - ->reject(function (ReflectionMethod $method) use ($model) { |
|
| 34 | - return $method->class !== $model || $method->getNumberOfParameters() > 0 || $method->isStatic();; |
|
| 33 | + ->reject(function(ReflectionMethod $method) use ($model) { |
|
| 34 | + return $method->class !== $model || $method->getNumberOfParameters() > 0 || $method->isStatic(); ; |
|
| 35 | 35 | }); |
| 36 | 36 | |
| 37 | 37 | $relations = Collection::make(); |
| 38 | 38 | |
| 39 | - $methods->map(function (ReflectionMethod $method) use ($model, &$relations) { |
|
| 39 | + $methods->map(function(ReflectionMethod $method) use ($model, &$relations) { |
|
| 40 | 40 | $relations = $relations->merge($this->getRelationshipFromMethodAndModel($method, $model)); |
| 41 | 41 | }); |
| 42 | 42 | |
| 43 | 43 | $relations = $relations->filter(); |
| 44 | 44 | |
| 45 | - if ($ignoreRelations = Arr::get(config('erd-generator.ignore', []),$model)) |
|
| 45 | + if ($ignoreRelations = Arr::get(config('erd-generator.ignore', [ ]), $model)) |
|
| 46 | 46 | { |
| 47 | 47 | $relations = $relations->diffKeys(array_flip($ignoreRelations)); |
| 48 | 48 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | { |
| 14 | 14 | if ($this->app->runningInConsole()) { |
| 15 | 15 | $this->publishes([ |
| 16 | - __DIR__.'/../config/config.php' => base_path('config/erd-generator.php'), |
|
| 16 | + __DIR__ . '/../config/config.php' => base_path('config/erd-generator.php'), |
|
| 17 | 17 | ], 'config'); |
| 18 | 18 | } |
| 19 | 19 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function register() |
| 25 | 25 | { |
| 26 | - $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'erd-generator'); |
|
| 26 | + $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'erd-generator'); |
|
| 27 | 27 | |
| 28 | 28 | $this->app->bind('command.generate:diagram', GenerateDiagramCommand::class); |
| 29 | 29 | |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | }); |
| 45 | 45 | |
| 46 | 46 | if(!count($whitelistModels)) { |
| 47 | - return $collection->diff($ignoreModels)->sort(); |
|
| 47 | + return $collection->diff($ignoreModels)->sort(); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | return $collection->filter(function (string $className) use ($whitelistModels) { |
@@ -27,27 +27,26 @@ discard block |
||
| 27 | 27 | public function getModelsInDirectory(string $directory): Collection |
| 28 | 28 | { |
| 29 | 29 | $files = config('erd-generator.recursive') ? |
| 30 | - $this->filesystem->allFiles($directory) : |
|
| 31 | - $this->filesystem->files($directory); |
|
| 30 | + $this->filesystem->allFiles($directory) : $this->filesystem->files($directory); |
|
| 32 | 31 | |
| 33 | - $ignoreModels = array_filter(config('erd-generator.ignore', []), 'is_string'); |
|
| 34 | - $whitelistModels = array_filter(config('erd-generator.whitelist', []), 'is_string'); |
|
| 32 | + $ignoreModels = array_filter(config('erd-generator.ignore', [ ]), 'is_string'); |
|
| 33 | + $whitelistModels = array_filter(config('erd-generator.whitelist', [ ]), 'is_string'); |
|
| 35 | 34 | |
| 36 | - $collection = Collection::make($files)->filter(function ($path) { |
|
| 35 | + $collection = Collection::make($files)->filter(function($path) { |
|
| 37 | 36 | return Str::endsWith($path, '.php'); |
| 38 | - })->map(function ($path) { |
|
| 37 | + })->map(function($path) { |
|
| 39 | 38 | return $this->getFullyQualifiedClassNameFromFile($path); |
| 40 | - })->filter(function (string $className) { |
|
| 39 | + })->filter(function(string $className) { |
|
| 41 | 40 | return !empty($className) |
| 42 | 41 | && is_subclass_of($className, EloquentModel::class) |
| 43 | - && ! (new ReflectionClass($className))->isAbstract(); |
|
| 42 | + && !(new ReflectionClass($className))->isAbstract(); |
|
| 44 | 43 | }); |
| 45 | 44 | |
| 46 | - if(!count($whitelistModels)) { |
|
| 45 | + if (!count($whitelistModels)) { |
|
| 47 | 46 | return $collection->diff($ignoreModels)->sort(); |
| 48 | 47 | } |
| 49 | 48 | |
| 50 | - return $collection->filter(function (string $className) use ($whitelistModels) { |
|
| 49 | + return $collection->filter(function(string $className) use ($whitelistModels) { |
|
| 51 | 50 | return in_array($className, $whitelistModels); |
| 52 | 51 | }); |
| 53 | 52 | } |
@@ -68,19 +67,19 @@ discard block |
||
| 68 | 67 | $statements = $traverser->traverse($statements); |
| 69 | 68 | |
| 70 | 69 | // get the first namespace declaration in the file |
| 71 | - $root_statement = collect($statements)->first(function ($statement) { |
|
| 70 | + $root_statement = collect($statements)->first(function($statement) { |
|
| 72 | 71 | return $statement instanceof Namespace_; |
| 73 | 72 | }); |
| 74 | 73 | |
| 75 | - if (! $root_statement) { |
|
| 74 | + if (!$root_statement) { |
|
| 76 | 75 | return ''; |
| 77 | 76 | } |
| 78 | 77 | |
| 79 | 78 | return collect($root_statement->stmts) |
| 80 | - ->filter(function ($statement) { |
|
| 79 | + ->filter(function($statement) { |
|
| 81 | 80 | return $statement instanceof Class_; |
| 82 | 81 | }) |
| 83 | - ->map(function (Class_ $statement) { |
|
| 82 | + ->map(function(Class_ $statement) { |
|
| 84 | 83 | return $statement->namespacedName->toString(); |
| 85 | 84 | }) |
| 86 | 85 | ->first() ?? ''; |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | } catch (\Throwable $e) { |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - return []; |
|
| 58 | + return [ ]; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | protected function getModelLabel(EloquentModel $model, string $label) |
| 62 | 62 | { |
| 63 | 63 | |
| 64 | 64 | $table = '<<table width="100%" height="100%" border="0" margin="0" cellborder="1" cellspacing="0" cellpadding="10">' . PHP_EOL; |
| 65 | - $table .= '<tr width="100%"><td width="100%" bgcolor="'.config('erd-generator.table.header_background_color').'"><font color="'.config('erd-generator.table.header_font_color').'">' . $label . '</font></td></tr>' . PHP_EOL; |
|
| 65 | + $table .= '<tr width="100%"><td width="100%" bgcolor="' . config('erd-generator.table.header_background_color') . '"><font color="' . config('erd-generator.table.header_font_color') . '">' . $label . '</font></td></tr>' . PHP_EOL; |
|
| 66 | 66 | |
| 67 | 67 | if (config('erd-generator.use_db_schema')) { |
| 68 | 68 | $columns = $this->getTableColumnsFromModel($model); |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | $name = $column->getName(); |
| 72 | 72 | $typeName = $column->getType()->getName(); |
| 73 | 73 | } else { // it's an array! |
| 74 | - $name = $column['name']; |
|
| 75 | - $typeName = $column['type_name']; |
|
| 74 | + $name = $column[ 'name' ]; |
|
| 75 | + $typeName = $column[ 'type_name' ]; |
|
| 76 | 76 | } |
| 77 | 77 | $label = $name; |
| 78 | 78 | if (config('erd-generator.use_column_types')) { |
| 79 | - $label .= ' ('. $typeName .')'; |
|
| 79 | + $label .= ' (' . $typeName . ')'; |
|
| 80 | 80 | } |
| 81 | - $table .= '<tr width="100%"><td port="' . $name . '" align="left" width="100%" bgcolor="'.config('erd-generator.table.row_background_color').'"><font color="'.config('erd-generator.table.row_font_color').'" >' . $label . '</font></td></tr>' . PHP_EOL; |
|
| 81 | + $table .= '<tr width="100%"><td port="' . $name . '" align="left" width="100%" bgcolor="' . config('erd-generator.table.row_background_color') . '"><font color="' . config('erd-generator.table.row_font_color') . '" >' . $label . '</font></td></tr>' . PHP_EOL; |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
@@ -90,13 +90,13 @@ discard block |
||
| 90 | 90 | protected function addModelsToGraph(Collection $models) |
| 91 | 91 | { |
| 92 | 92 | // Add models to graph |
| 93 | - $models->map(function (Model $model) { |
|
| 93 | + $models->map(function(Model $model) { |
|
| 94 | 94 | $eloquentModel = app($model->getModel()); |
| 95 | 95 | $this->addNodeToGraph($eloquentModel, $model->getNodeName(), $model->getLabel()); |
| 96 | 96 | }); |
| 97 | 97 | |
| 98 | 98 | // Create relations |
| 99 | - $models->map(function ($model) { |
|
| 99 | + $models->map(function($model) { |
|
| 100 | 100 | $this->addRelationToGraph($model); |
| 101 | 101 | }); |
| 102 | 102 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $edge->{"set{$key}"}($value); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - foreach (config('erd-generator.relations.' . $relation->getType(), []) as $key => $value) { |
|
| 148 | + foreach (config('erd-generator.relations.' . $relation->getType(), [ ]) as $key => $value) { |
|
| 149 | 149 | $edge->{"set{$key}"}($value); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | 208 | $this->connectNodes($pivotModelNode, $relatedModelNode, $relation); |
| 209 | - } catch (\ReflectionException $e){} |
|
| 209 | + } catch (\ReflectionException $e) {} |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |