| Conditions | 11 | 
| Paths | 43 | 
| Total Lines | 42 | 
| Code Lines | 26 | 
| 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  | 
            ||
| 26 | public function page(\Base $f3, array $params = [])  | 
            ||
| 27 |     { | 
            ||
| 28 |         if (array_key_exists('slug', $params)) { | 
            ||
| 29 | $slug = $params['slug'];  | 
            ||
| 30 |         } elseif (preg_match('/^\/(?P<lang>[^\/]+)\/(?P<slug>.+)/', $f3->get('PATH'), $matches)) { | 
            ||
| 31 | $slug = $matches['slug'];  | 
            ||
| 32 |         } else { | 
            ||
| 33 | // 404  | 
            ||
| 34 | echo 'missing slug';  | 
            ||
| 35 | die(404);  | 
            ||
| 36 | }  | 
            ||
| 37 | |||
| 38 |         if (empty($slug)) { | 
            ||
| 39 | // 404  | 
            ||
| 40 | echo 'page does not exist';  | 
            ||
| 41 | die(404);  | 
            ||
| 42 | }  | 
            ||
| 43 | |||
| 44 | $page = new Mappers\Pages;  | 
            ||
| 45 | $page->load(['slug = ?', $slug]);  | 
            ||
| 46 | |||
| 47 | // conditions if page is viewable  | 
            ||
| 48 | $publishTime = strtotime($page->published);  | 
            ||
| 49 | $expireTime = strtotime($page->expires);  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 50 |         $showPage = $f3->get('REQUEST.preview') || ( | 
            ||
| 51 | 'published' == $page->status &&  | 
            ||
| 52 | 'public' == $page->scopes &&  | 
            ||
| 53 | 'page' == $page->category &&  | 
            ||
| 54 | time() > $publishTime &&  | 
            ||
| 55 | (0 >= $expireTime || $expireTime > time())  | 
            ||
| 56 | );  | 
            ||
| 57 | |||
| 58 |         if (!$showPage) { | 
            ||
| 59 | // 404  | 
            ||
| 60 | echo 'page unavailable';  | 
            ||
| 61 | die(404);  | 
            ||
| 62 | }  | 
            ||
| 63 | |||
| 64 |         $f3->set('pagesMapper', $page); | 
            ||
| 65 | |||
| 66 | echo \View::instance()->render($this->template_path . '/page.phtml');  | 
            ||
| 67 | }  | 
            ||
| 68 | }  | 
            ||
| 69 | 
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.