| Conditions | 2 |
| Paths | 2 |
| Total Lines | 56 |
| Code Lines | 20 |
| 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 |
||
| 24 | private function getLayout(Template\Block $contents) { |
||
| 25 | |||
| 26 | $layout = View::get('Layouts/' . $this->layout); |
||
| 27 | |||
| 28 | # Set menu and user |
||
| 29 | |||
| 30 | if (Auth::check()) { |
||
| 31 | |||
| 32 | $layout->menu = View::get('Blocks/Utils/Menu'); |
||
| 33 | |||
| 34 | $layout->getBlock('user')->gravatar = Auth::user()->gravatar; |
||
| 35 | |||
| 36 | $layout->getBlock('user')->name = Auth::user()->name; |
||
| 37 | |||
| 38 | $layout->getBlock('user')->id = Auth::user()->id; |
||
| 39 | } |
||
| 40 | |||
| 41 | # Set title |
||
| 42 | |||
| 43 | $layout->title = Language::get($this->title); |
||
| 44 | |||
| 45 | # Set messages |
||
| 46 | |||
| 47 | $layout->messages = Messages::block(); |
||
| 48 | |||
| 49 | # Set contents |
||
| 50 | |||
| 51 | $layout->contents = $contents; |
||
| 52 | |||
| 53 | # Set personalizer |
||
| 54 | |||
| 55 | $layout->getBlock('language')->country = Extend\Languages::data('country'); |
||
| 56 | |||
| 57 | $layout->getBlock('language')->title = Extend\Languages::data('title'); |
||
| 58 | |||
| 59 | # Set copyright |
||
| 60 | |||
| 61 | $layout->cadmium_home = CADMIUM_HOME; |
||
| 62 | $layout->cadmium_copy = CADMIUM_COPY; |
||
| 63 | $layout->cadmium_name = CADMIUM_NAME; |
||
| 64 | $layout->cadmium_version = CADMIUM_VERSION; |
||
| 65 | |||
| 66 | # Set popup |
||
| 67 | |||
| 68 | $layout->popup = Popup::block(); |
||
| 69 | |||
| 70 | # Set report |
||
| 71 | |||
| 72 | $layout->getBlock('report')->script_time = Debug::getTime(); |
||
| 73 | |||
| 74 | $layout->getBlock('report')->db_time = DB::getTime(); |
||
| 75 | |||
| 76 | # ------------------------ |
||
| 77 | |||
| 78 | return $layout; |
||
| 79 | } |
||
| 80 | |||
| 123 |