Completed
Pull Request — master (#296)
by
unknown
13:28
created

Publishdate::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * COPS (Calibre OPDS PHP Server) class file
5
 *
6
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
7
 * @author     <[email protected]>
8
 */
9
require_once('base.php');
10
11
class Publishdate extends Base {
12
13
    const ALL_PUBLISHDATES_ID = "cops:publishdates";
14
    const PUBLISHDATE_COLUMNS = "strftime('%Y', pubdate) as name, count(*) as count";
15
    const SQL_ALL_PUBLISHDATES = "select {0} from books group by name order by name DESC";
16
    const SQL_PUBLISHDATE_COUNT = "select count(DISTINCT strftime('%Y', pubdate)) from books";
17
18
    public $id;
19
    public $name;
20
21
    public function __construct($post) {
22
        $this->id = $post->name;
23
        $this->name = $post->name;
24
    }
25
26
    public function getUri() {
27
        return "?page=" . parent::PAGE_PUBLISHDATE_YEAR . "&id=$this->id";
28
    }
29
30
    public function getEntryId() {
31
        return self::ALL_PUBLISHDATES_ID . ":" . $this->id;
32
    }
33
34
    public static function getCount() {
35
        return parent::getCountGeneric("pubdate", self::ALL_PUBLISHDATES_ID, parent::PAGE_ALL_PUBLISHDATES, "pubdate", self::SQL_PUBLISHDATE_COUNT);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getCountGeneric() instead of getCount()). Are you sure this is correct? If so, you might want to change this to $this->getCountGeneric().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
36
    }
37
38
    public static function getAllPublishdates() {
39
        return Base::getEntryArrayWithBookNumber(self::SQL_ALL_PUBLISHDATES, self::PUBLISHDATE_COLUMNS, array(), "Publishdate");
40
    }
41
42
}
43