Comment   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 76
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A addComment() 0 7 1
A convertEmail() 0 4 1
A deletePost() 0 4 1
A updateComment() 0 8 1
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