Completed
Push — master ( c05070...1cf9f6 )
by Anton
01:59
created

Row::prepareData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 12
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
/**
3
 * @copyright Bluz PHP Team
4
 * @link https://github.com/bluzphp/skeleton
5
 */
6
7
/**
8
 * @namespace
9
 */
10
namespace Application\ContactUs;
11
12
use Bluz\Validator\Traits\Validator;
13
use Bluz\Validator\Validator as v;
14
15
/**
16
 * Options Row
17
 *
18
 * @property int $id
19
 * @property string $name
20
 * @property string $email
21
 * @property string $subject
22
 * @property string $message
23
 * @property boolean $mark_read
24
 * @property boolean $mark_answered
25
 * @property string $created
26
 * @property string $updated
27
 *
28
 * @category Application
29
 * @package  ContactUs
30
 */
31
class Row extends \Bluz\Db\Row
32
{
33
    use Validator;
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    protected function beforeSave()
39
    {
40
        $this->addValidator(
41
            'name',
42
            v::required()->setError('Value is required')
43
        );
44
        $this->addValidator(
45
            'email',
46
            v::required()->setError('Value is required'),
47
            v::email()->setError('Please fill correct email address')
48
        );
49
        $this->addValidator(
50
            'message',
51
            v::required()->setError('Value is required')
52
        );
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function beforeInsert()
59
    {
60
        $this->created = gmdate('Y-m-d H:i:s');
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    protected function beforeUpdate()
67
    {
68
        $this->updated = gmdate('Y-m-d H:i:s');
69
    }
70
}
71