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

PublishdateYear   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getUri() 0 3 1
A getEntryId() 0 3 1
A getCount() 0 3 1
A getAllPublishdateMonth() 0 3 1
A getPublishdateMonth() 0 7 1
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 PublishdateYear extends Base {
12
13
    const PUBLISHDATE_YEAR_ID = "cops:publishdatesyear";
14
    const PUBLISHDATE_YEAR_COLUMNS = "strftime('%Y-%m', pubdate) as name, count(*) as count";
15
    const SQL_PUBLISHDATE_YEAR = "select {0} from books where name LIKE :year group by name order by name ASC";
16
    const SQL_PUBLISHDATE_YEAR_COUNT = "select count(DISTINCT strftime('%Y-%m', 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_MONTH . "&id=$this->id";
28
    }
29
30
    public function getEntryId() {
31
        return self::PUBLISHDATE_YEAR_ID . ":" . $this->id;
32
    }
33
34
    public static function getCount() {
35
        return parent::getCountGeneric("pubdate", self::PUBLISHDATE_YEAR_ID, parent::PAGE_PUBLISHDATE_YEAR, "pubdate", self::SQL_PUBLISHDATE_YEAR_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 getAllPublishdateMonth($id) {
39
        return Base::getEntryArrayWithBookNumber(self::SQL_PUBLISHDATE_YEAR, self::PUBLISHDATE_YEAR_COLUMNS, array('year' => $id."%"), "PublishdateYear");
40
    }
41
42
    public static function getPublishdateMonth ($id) {
43
        $post = array(
44
            'id' => $id, 
45
            'name' => $id
46
        );
47
        return new PublishdateYear ($post);
48
    }
49
}
50