Conditions | 1 |
Paths | 1 |
Total Lines | 77 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
49 | public function makeCapsule($capsule, $basePath) |
||
50 | { |
||
51 | $capsule['name'] = Str::studly($capsule['name']); |
||
52 | |||
53 | $capsule['module'] = Str::camel($capsule['name']); |
||
54 | |||
55 | $capsule['plural'] = $name = $capsule['name']; |
||
56 | |||
57 | $capsule['singular'] = $singular = |
||
58 | $capsule['singular'] ?? Str::singular($name); |
||
59 | |||
60 | $twillNamespace = config('twill.namespace'); |
||
|
|||
61 | |||
62 | $capsule[ |
||
63 | 'namespace' |
||
64 | ] = $capsuleNamespace = $this->getManager()->capsuleNamespace( |
||
65 | $capsule['name'] |
||
66 | ); |
||
67 | |||
68 | $capsule['model'] = $capsule['models'] = $models = |
||
69 | "{$capsuleNamespace}\\" . |
||
70 | config('twill.capsules.namespaces.models'); |
||
71 | $capsule['repositories'] = $repositories = |
||
72 | "{$capsuleNamespace}\\" . |
||
73 | config('twill.capsules.namespaces.repositories'); |
||
74 | $capsule['controllers'] = $controllers = |
||
75 | "{$capsuleNamespace}\\" . |
||
76 | config('twill.capsules.namespaces.controllers'); |
||
77 | $capsule['requests'] = $requests = |
||
78 | "{$capsuleNamespace}\\" . |
||
79 | config('twill.capsules.namespaces.requests'); |
||
80 | |||
81 | $capsule['psr4_path'] = "$basePath/{$name}/app"; |
||
82 | |||
83 | $capsule['root_path'] = $root = $this->capsuleRootPath($capsule); |
||
84 | |||
85 | $capsule[ |
||
86 | 'migrations_dir' |
||
87 | ] = "{$capsule['root_path']}/database/migrations"; |
||
88 | |||
89 | $capsule['views_dir'] = "{$capsule['root_path']}/resources/views"; |
||
90 | |||
91 | $capsule['view_prefix'] = "{$name}.resources.views.admin"; |
||
92 | |||
93 | $capsule['routes_file'] = "{$capsule['root_path']}/routes/admin.php"; |
||
94 | |||
95 | $capsule['model'] = "{$models}\\{$singular}"; |
||
96 | |||
97 | $capsule['models_dir'] = $this->namespaceToPath($capsule, $models); |
||
98 | |||
99 | $capsule['translation'] = "{$models}\\{$singular}Translation"; |
||
100 | |||
101 | $capsule['slug'] = "{$models}\\{$singular}Slug"; |
||
102 | |||
103 | $capsule['revision'] = "{$models}\\{$singular}Revision"; |
||
104 | |||
105 | $capsule['repository'] = "{$repositories}\\{$singular}Repository"; |
||
106 | |||
107 | $capsule['repositories_dir'] = $this->namespaceToPath( |
||
108 | $capsule, |
||
109 | $repositories |
||
110 | ); |
||
111 | |||
112 | $capsule['controller'] = "{$controllers}\\{$singular}Controller"; |
||
113 | |||
114 | $capsule['controllers_dir'] = $this->namespaceToPath( |
||
115 | $capsule, |
||
116 | $controllers |
||
117 | ); |
||
118 | |||
119 | $capsule['formRequest'] = "{$requests}\\{$singular}Request"; |
||
120 | |||
121 | $capsule['requests_dir'] = $this->namespaceToPath($capsule, $requests); |
||
122 | |||
123 | $this->registerPsr4Autoloader($capsule); |
||
124 | |||
125 | return $capsule; |
||
126 | } |
||
201 |