Comment   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
dl 0
loc 63
ccs 13
cts 14
cp 0.9286
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getComment() 0 12 4
A getAllComments() 0 18 1
1
<?php
2
3
namespace Alvo\Comment;
4
5
use \Anax\Database\ActiveRecordModel;
6
use \Anax\DI\InjectionAwareInterface;
7
use \Anax\DI\InjectionAwareTrait;
8
9
class Comment extends ActiveRecordModel
10
{
11
    /**
12
     * @var string $tableName name of the database table.
13
     */
14
    protected $tableName = "Comment";
15
16
    /**
17
     * Columns in the table.
18
     *
19
     * @var integer $id primary key auto incremented.
20
     */
21
    public $id;
22
    public $text;
23
    public $heading;
24
    public $created;
25
    public $tags;
26
    public $userId;
27
28
29
30 1
    public function getAllComments()
31
    {
32 1
        return $this->db->connect()
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->db->connect()->se...r.id = Comment.userId') targeting Anax\Database\DatabaseQueryBuilder::join() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
33 1
                    ->select("
34
                        Comment.id,
35
                        Comment.text,
36
                        Comment.heading,
37
                        Comment.created,
38
                        Comment.tags,
39
                        Comment.userId,
40
                        User.email
41
                    ")
42 1
                    ->from($this->tableName)
43 1
                    ->where("Comment.deleted IS NULL")
44 1
                    ->join("User", "User.id = Comment.userId")
45
                    // ->getSQL();
46 1
                    ->execute()
47 1
                    ->fetchAllClass(get_class($this));
48
49
        // debug($t);
50
        // return $this->db->connect()
51
        //             ->select()
52
        //             ->from($this->tableName)
53
        //             ->where("deleted IS NULL")
54
        //             ->execute()
55
        //             ->fetchAllClass(get_class($this));
56
    }
57
58
59
60 3
    public function getComment($col = null, $val = null)
61
    {
62
        // debug($col);
63 3
        if (!$col) {
64 2
            $col = "id";
65
        }
66
67 3
        if (!$val && $val != 0) {
68
            throw new \Exception("CUSTOM ERR | No value provided to getComment");
69
        }
70
71 3
        return $this->find($col, $val);
72
    }
73
}
74