| Conditions | 9 |
| Paths | 21 |
| Total Lines | 32 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public function page(\Base $f3, array $params = []) |
||
| 27 | { |
||
| 28 | if (empty($params['slug'])) { |
||
| 29 | // 404 |
||
| 30 | echo 'page does not exist'; |
||
| 31 | die(404); |
||
| 32 | } |
||
| 33 | |||
| 34 | $page = new Mappers\Pages; |
||
| 35 | $page->load(['slug = ?', $params['slug']]); |
||
| 36 | |||
| 37 | // conditions if page is viewable |
||
| 38 | $publishTime = strtotime($page->published); |
||
| 39 | $expireTime = strtotime($page->expires); |
||
|
|
|||
| 40 | $showPage = $f3->get('REQUEST.preview') || ( |
||
| 41 | 'published' == $page->status && |
||
| 42 | 'public' == $page->scopes && |
||
| 43 | 'page' == $page->category && |
||
| 44 | time() > $publishTime && |
||
| 45 | (0 >= $expireTime || $expireTime > time()) |
||
| 46 | ); |
||
| 47 | |||
| 48 | if (!$showPage) { |
||
| 49 | // 404 |
||
| 50 | echo 'page unavailable'; |
||
| 51 | die(404); |
||
| 52 | } |
||
| 53 | |||
| 54 | $f3->set('pagesMapper', $page); |
||
| 55 | |||
| 56 | echo \View::instance()->render($this->template_path . '/page.phtml'); |
||
| 57 | } |
||
| 58 | } |
||
| 59 |
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.