Conditions | 3 |
Paths | 3 |
Total Lines | 75 |
Code Lines | 49 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
100 | public function make() |
||
101 | { |
||
102 | // prepare configurations to save |
||
103 | /** @var array $cfg */ |
||
104 | $cfg = App::$Properties->getAll('default'); |
||
105 | $this->before(); |
||
106 | $cfg['baseDomain'] = $this->baseDomain; |
||
107 | $cfg['database'] = $this->db; |
||
108 | $cfg['singleLanguage'] = $this->singleLanguage; |
||
109 | $cfg['multiLanguage'] = (bool)$this->multiLanguage; |
||
110 | $cfg['debug']['cookie']['key'] = 'fdebug_' . Crypt::randomString(mt_rand(4, 16)); |
||
111 | $cfg['debug']['cookie']['value'] = Crypt::randomString(mt_rand(32, 128)); |
||
112 | $cfg['mail'] = $this->mail; |
||
113 | |||
114 | // initialize migrations table |
||
115 | App::$Database->getConnection('install')->getSchemaBuilder()->create('migrations', function ($table) { |
||
116 | $table->increments('id'); |
||
117 | $table->string('migration', 128)->unique(); |
||
118 | $table->timestamps(); |
||
119 | }); |
||
120 | |||
121 | // import migrations |
||
122 | $manager = new MigrationsManager(null, 'install'); |
||
123 | $search = $manager->search(null, false); |
||
124 | $manager->makeUp($search); |
||
|
|||
125 | |||
126 | // insert admin user |
||
127 | $user = new User(); |
||
128 | $user->setConnection('install'); |
||
129 | $user->email = $this->user['email']; |
||
130 | $user->role_id = 4; |
||
131 | $user->password = Crypt::passwordHash($this->user['password']); |
||
132 | $user->save(); |
||
133 | |||
134 | $profile = new Profile(); |
||
135 | $profile->setConnection('install'); |
||
136 | $profile->user_id = $user->id; |
||
137 | $profile->save(); |
||
138 | |||
139 | // set installation version |
||
140 | $system = new System(); |
||
141 | $system->setConnection('install'); |
||
142 | $system->var = 'version'; |
||
143 | $system->data = Version::VERSION; |
||
144 | $system->save(); |
||
145 | |||
146 | // write config data |
||
147 | App::$Properties->writeConfig('default', $cfg); |
||
148 | // make routing configs based on preset property |
||
149 | $routing = []; |
||
150 | switch ($this->mainpage) { |
||
151 | case 'news': |
||
152 | $routing = [ |
||
153 | 'Alias' => [ |
||
154 | 'Front' => [ |
||
155 | '/' => '/content/list/news', |
||
156 | '/about' => '/content/read/page/about-page' |
||
157 | ] |
||
158 | ] |
||
159 | ]; |
||
160 | break; |
||
161 | case 'about': |
||
162 | $routing = [ |
||
163 | 'Alias' => [ |
||
164 | 'Front' => [ |
||
165 | '/' => '/content/read/page/about-page' |
||
166 | ] |
||
167 | ] |
||
168 | ]; |
||
169 | break; |
||
170 | } |
||
171 | // write routing configurations |
||
172 | App::$Properties->writeConfig('routing', $routing); |
||
173 | // write installer lock |
||
174 | File::write('/Private/Install/install.lock', 'Installation is locked!'); |
||
175 | } |
||
195 |