Comment   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 45
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getComments() 0 16 1
1
<?php
2
3
namespace Nicklas\Comment\Modules;
4
5
/**
6
 * A database driven model.
7
 */
8
class Comment extends ActiveRecordModelExtender
9
{
10
11
        /**
12
     * @var string $tableName name of the database table.
13
     */
14
    protected $tableName = "coffee_comments";
15
16
    /**
17
     * Columns in the table.
18
     *
19
     * @var integer $id primary key auto incremented.
20
     */
21
    public $id;
22
    public $user; # question/answer/comment
23
    public $parentId; # All posts have different ids
24
25
    public $text;
26
27
    public $created;
28
29
    /**
30
     * Returns post with markdown and gravatar
31
     * @param string $sql
32
     * @param array $param
0 ignored issues
show
Documentation introduced by
There is no parameter named $param. Did you maybe mean $params?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
33
     *
34
     * @return array
35
     */
36 10
    public function getComments($sql, $params)
37
    {
38 10
        $comments = $this->findAllWhere("$sql", $params);
39
40 10
        return array_map(function ($comment) {
41 9
            $user = new User($this->db);
42 9
            $comment->img = $user->getGravatar($comment->user);
43 9
            $comment->markdown = $this->getMD($comment->text);
44
45
            // Get votes for Post
46 9
            $vote = new Vote($this->db);
47 9
            $comment->vote = $vote->getVote("parentId = ? AND parentType = ?", [$comment->id, "comment"]);
48
49 9
            return $comment;
50 10
        }, $comments);
51
    }
52
}
53