Comment::convertEmail()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Anax\Comment;
4
5
use \Anax\Database\ActiveRecordModel;
6
7
/**
8
 * A database driven model.
9
 */
10
class Comment extends ActiveRecordModel
11
{
12
13
    /**
14
     * @var string $tableName name of the database table.
15
     */
16
    protected $tableName = "Comment";
17
18
    /**
19
     * Columns in the table.
20
     *
21
     * @var integer $id primary key auto incremented.
22
     */
23
    public $id;
24
    public $user;
25
    public $gravatar;
26
    public $content;
27
28
    /**
29
     * Add a comment to the session.
30
     *
31
     * @param string $username
32
     * @param string $comment
33
     * @param string $gravatar
34
     *
35
     * @return void
36
     */
37 1
    public function addComment($username, $comment, $gravatar)
38
    {
39 1
        $this->user  = $username;
40 1
        $this->content = $comment;
41 1
        $this->gravatar = $gravatar;
42 1
        $this->save();
43 1
    }
44
45
    /**
46
     * Convert email to md5 string
47
     *
48
     * @return string
49
     */
50 1
    public function convertEmail($email)
51
    {
52 1
        return md5(strtolower(trim($email)));
53
    }
54
55
    /**
56
    * Delete post
57
    *@param int id
58
    *
59
    *@return void
60
    */
61
62 1
    public function deletePost($id)
63
    {
64 1
        $this->delete($id);
65 1
    }
66
67
    /**
68
     * Update Comment
69
     *
70
     * @param int $id
71
     * @param string $user
72
     * @param string $content
73
     * @param string $gravatar
74
     *
75
     * @return void
76
     */
77 1
    public function updateComment($id, $user, $content, $gravatar)
78
    {
79 1
        $this->find("id", $id);
80 1
        $this->user = $user;
81 1
        $this->content = $content;
82 1
        $this->gravatar = $gravatar;
83 1
        $this->save();
84 1
    }
85
}
86