Completed
Push — dev-master ( 4ebc69...e67cd9 )
by Vijay
03:21
created

Contact::contactPost()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace FFCMS\Controllers;
4
5
use FFCMS\{Mappers};
6
7
8
/**
9
 * Contact Page Controller Class.
10
 *
11
 * @author Vijay Mahrra <[email protected]>
12
 * @copyright (c) Copyright 2016 Vijay Mahrra
13
 * @license GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html)
14
 */
15
class Contact extends Base
16
{
17
    protected $template_path = 'pages/';
18
19
    /**
20
     * Make contact page
21
     *
22
     * @param \Base $f3
23
     * @param array $params
24
     * @return void
25
     */
26
    public function contact(\Base $f3, array $params = [])
0 ignored issues
show
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
    {
28
        $page = new Mappers\Pages;
29
        $page->load(['slug = ?', 'contact']);
30
31
        // conditions if page is viewable
32
        $publishTime = strtotime($page->published);
33
        $expireTime = strtotime($page->expires);
0 ignored issues
show
Documentation introduced by
The property expires does not exist on object<FFCMS\Mappers\Pages>. Since you implemented __get, maybe consider adding a @property annotation.

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 @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

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.

Loading history...
34
        $showPage = $f3->get('REQUEST.preview') || (
35
            'published' == $page->status &&
36
            'public' == $page->scopes &&
37
            'page' == $page->category &&
38
            time() > $publishTime &&
39
            (0 >= $expireTime || $expireTime > time())
40
        );
41
42
        if (!$showPage) {
43
            // 404
44
            echo 'page unavailable';
45
            die(404);
46
        }
47
48
        $f3->set('pagesMapper', $page);
49
50
        echo \View::instance()->render($this->template_path . '/contact.phtml');
51
    }
52
53
    /**
54
     * Contact page form post handler
55
     *
56
     * @param \Base $f3
57
     * @param array $params
58
     * @return void
59
     */
60
    public function contactPost(\Base $f3, array $params = [])
0 ignored issues
show
Unused Code introduced by
The parameter $f3 is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
61
    {
62
        // handle form input, send email
63
        
64
        echo \View::instance()->render($this->template_path . '/contact.phtml');
65
    }
66
67
}
68