| Conditions | 3 |
| Paths | 3 |
| Total Lines | 78 |
| Code Lines | 64 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 48 | public function handle() |
||
| 49 | { |
||
| 50 | $name = $this->ask('What is name of the site? '); |
||
| 51 | $slug = $this->ask('What is the unique slug of the site? '); |
||
| 52 | $domain = $this->ask('What will be the domain of this site? E.G. http://google.be '); |
||
| 53 | |||
| 54 | // Validate user input |
||
| 55 | $this->info('Validating your information and generating a new site...'); |
||
| 56 | |||
| 57 | $data = [ |
||
| 58 | 'name' => $name, |
||
| 59 | 'slug' => $slug, |
||
| 60 | 'domain' => $domain, |
||
| 61 | ]; |
||
| 62 | |||
| 63 | $rules = [ |
||
| 64 | 'name' => 'required|max:185', |
||
| 65 | 'slug' => 'required|unique:sites', |
||
| 66 | 'domain' => 'required|min:11', |
||
| 67 | ]; |
||
| 68 | |||
| 69 | $validator = \Validator::make($data, $rules); |
||
| 70 | |||
| 71 | if ($validator->fails()) { |
||
| 72 | $messages = $validator->errors(); |
||
| 73 | foreach ($messages->all() as $message) { |
||
| 74 | $this->error($message); |
||
| 75 | } |
||
| 76 | } else { |
||
| 77 | $settings = []; |
||
| 78 | $settings['company']['name'] = 'ChuckCMS'; |
||
| 79 | $settings['company']['vat'] = 'BE0000.000.000'; |
||
| 80 | $settings['company']['street'] = 'Berlaarsestraat'; |
||
| 81 | $settings['company']['housenumber'] = '10'; |
||
| 82 | $settings['company']['postalcode'] = '2500'; |
||
| 83 | $settings['company']['city'] = 'Lier'; |
||
| 84 | $settings['company']['email'] = '[email protected]'; |
||
| 85 | $settings['company']['tel'] = '0470 12 34 56'; |
||
| 86 | $settings['socialmedia']['facebook'] = 'https://facebook.com/chuckcmsmedia'; |
||
| 87 | $settings['socialmedia']['twitter'] = 'https://twitter.com/chuckcms'; |
||
| 88 | $settings['socialmedia']['pinterest'] = 'https://pinterest.com/chuckcms'; |
||
| 89 | $settings['socialmedia']['instagram'] = 'https://instagram.com/chuckcms'; |
||
| 90 | $settings['socialmedia']['snapchat'] = 'https://snapchat.co/username'; |
||
| 91 | $settings['socialmedia']['googleplus'] = 'https://plus.google.com/+ChuckCMS'; |
||
| 92 | $settings['socialmedia']['tumblr'] = 'https://tumblr.com/chuckcms'; |
||
| 93 | $settings['socialmedia']['youtube'] = 'https://youtube.com/chuckcms'; |
||
| 94 | $settings['socialmedia']['vimeo'] = 'https://vimeo.com/chuckcms'; |
||
| 95 | $settings['integrations']['ga-id'] = null; |
||
| 96 | $settings['integrations']['g-site-verification'] = null; |
||
| 97 | $settings['favicon']['href'] = '/chuckbe/chuckcms/favicon.ico'; |
||
| 98 | $settings['logo']['href'] = '/chuckbe/chuckcms/chuckcms-logo.png'; |
||
| 99 | $settings['lang'] = 'nl,en'; |
||
| 100 | $settings['domain'] = $domain; |
||
| 101 | // create the site |
||
| 102 | $this->siteRepository->createFromArray([ |
||
| 103 | 'name' => $name, |
||
| 104 | 'slug' => $slug, |
||
| 105 | 'domain' => $domain, |
||
| 106 | 'settings' => $settings, |
||
| 107 | ]); |
||
| 108 | |||
| 109 | $this->info('. .'); |
||
| 110 | $this->info('.. ..'); |
||
| 111 | $this->info('... ...'); |
||
| 112 | $this->info('.... AWESOME ....'); |
||
| 113 | $this->info('... ...'); |
||
| 114 | $this->info('.. ..'); |
||
| 115 | $this->info('. .'); |
||
| 116 | $this->info('. .'); |
||
| 117 | $this->info('.. ..'); |
||
| 118 | $this->info('... ...'); |
||
| 119 | $this->info('.... JOB ....'); |
||
| 120 | $this->info('... ...'); |
||
| 121 | $this->info('.. ..'); |
||
| 122 | $this->info('. .'); |
||
| 123 | $this->info(' '); |
||
| 124 | $this->info('New site: '.$name.' ('.$domain.') generated successfully'); |
||
| 125 | $this->info(' '); |
||
| 126 | } |
||
| 129 |