| Conditions | 6 | 
| Paths | 18 | 
| Total Lines | 62 | 
| Code Lines | 40 | 
| 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 namespace VojtaSvoboda\Reservations\Components;  | 
            ||
| 52 | public function onRun()  | 
            ||
| 53 | 	{ | 
            ||
| 54 | $facade = $this->getFacade();  | 
            ||
| 55 | |||
| 56 | $error = false;  | 
            ||
| 57 | 		if (Input::get($this->alias . '-submit')) { | 
            ||
| 58 | |||
| 59 | // check CSRF token  | 
            ||
| 60 |             if (Session::token() != Input::get('_token')) { | 
            ||
| 61 |                 $error = Lang::get('vojtasvoboda.reservations::lang.errors.session_expired'); | 
            ||
| 62 |             } else { | 
            ||
| 63 |                 try { | 
            ||
| 64 | $data = Input::all();  | 
            ||
| 65 | $facade->storeReservation($data);  | 
            ||
| 66 |                     $msg = Lang::get('vojtasvoboda.reservations::lang.reservationform.success'); | 
            ||
| 67 | Flash::success($msg);  | 
            ||
| 68 | |||
| 69 | return Redirect::to($this->page->url . '#' . $this->alias, 303);  | 
            ||
| 70 | |||
| 71 |                 } catch(ValidationException $e) { | 
            ||
| 72 | $error = $e->getMessage();  | 
            ||
| 73 | |||
| 74 |                 } catch(ApplicationException $e) { | 
            ||
| 75 | $error = $e->getMessage();  | 
            ||
| 76 | |||
| 77 |                 } catch(Exception $e) { | 
            ||
| 78 | Log::error($e->getMessage());  | 
            ||
| 79 |                     $error = Lang::get('vojtasvoboda.reservations::lang.errors.exception'); | 
            ||
| 80 | }  | 
            ||
| 81 | }  | 
            ||
| 82 | }  | 
            ||
| 83 | |||
| 84 | // inject assets  | 
            ||
| 85 | $this->injectAssets();  | 
            ||
| 86 | |||
| 87 | // load booked dates and their time slots  | 
            ||
| 88 | $dates = $this->getReservedDates();  | 
            ||
| 89 | |||
| 90 | // template data  | 
            ||
| 91 | $this->page['sent'] = Flash::check();  | 
            ||
| 92 | $this->page['post'] = post();  | 
            ||
| 93 | $this->page['error'] = $error;  | 
            ||
| 94 | $this->page['dates'] = json_encode($dates);  | 
            ||
| 95 | $this->page['settings'] = [  | 
            ||
| 96 | 'formats_date' => Settings::get(  | 
            ||
| 97 | 'formats_date',  | 
            ||
| 98 |                 Config::get('vojtasvoboda.reservations::config.formats.date', 'd/m/Y') | 
            ||
| 99 | ),  | 
            ||
| 100 | 'formats_time' => Settings::get(  | 
            ||
| 101 | 'formats_time',  | 
            ||
| 102 |                 Config::get('vojtasvoboda.reservations::config.formats.time', 'H:i') | 
            ||
| 103 | ),  | 
            ||
| 104 | 'reservation_interval' => Settings::get(  | 
            ||
| 105 | 'reservation_interval',  | 
            ||
| 106 |                 Config::get('vojtasvoboda.reservations::config.reservation.interval', 15) | 
            ||
| 107 | ),  | 
            ||
| 108 |             'first_weekday'        => Settings::get('first_weekday', false), | 
            ||
| 109 |             'work_time_from'       => Settings::get('work_time_from', '10:00'), | 
            ||
| 110 |             'work_time_to'         => Settings::get('work_time_to', '18:00'), | 
            ||
| 111 |             'work_days'            => Settings::get('work_days', ['monday','tuesday','wednesday','thursday','friday']), | 
            ||
| 112 | ];  | 
            ||
| 113 | }  | 
            ||
| 114 | |||
| 166 |