Completed
Push — master ( d648a6...70bf01 )
by Sébastien
07:21 queued 12s
created

serie.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * COPS (Calibre OPDS PHP Server) class file
4
 *
5
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6
 * @author     S�bastien Lucas <[email protected]>
7
 */
8
9
require_once('base.php');
10
11
class Serie extends Base {
12
    const ALL_SERIES_ID = "cops:series";
13
    const SERIES_COLUMNS = "series.id as id, series.name as name, series.sort as sort, count(*) as count";
14
    const SQL_ALL_SERIES = "select {0} from series, books_series_link where series.id = series group by series.id, series.name, series.sort order by series.sort";
15
    const SQL_SERIES_FOR_SEARCH = "select {0} from series, books_series_link where series.id = series and upper (series.name) like ? group by series.id, series.name, series.sort order by series.sort";
16
17
    public $id;
18
    public $name;
19
20 46
    public function __construct($post) {
21 46
        $this->id = $post->id;
22 46
        $this->name = $post->name;
23 46
    }
24
25 46
    public function getUri () {
26 46
        return "?page=".parent::PAGE_SERIE_DETAIL."&id=$this->id";
27
    }
28
29 7
    public function getEntryId () {
30 7
        return self::ALL_SERIES_ID.":".$this->id;
31
    }
32
33 7
    public static function getCount() {
34
        // str_format (localize("series.alphabetical", count(array))
35 7
        return parent::getCountGeneric ("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES);
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 45
    public static function getSerieByBookId ($bookId) {
39 45
        $result = parent::getDb ()->prepare('select  series.id as id, name
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getDb() instead of getSerieByBookId()). Are you sure this is correct? If so, you might want to change this to $this->getDb().

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...
40
from books_series_link, series
41 45
where series.id = series and book = ?');
42 45
        $result->execute (array ($bookId));
43 45
        if ($post = $result->fetchObject ()) {
44 40
            return new Serie ($post);
45
        }
46 19
        return NULL;
47
    }
48
49 1
    public static function getSerieById ($serieId) {
50 1
        $result = parent::getDb ()->prepare('select id, name  from series where id = ?');
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getDb() instead of getSerieById()). Are you sure this is correct? If so, you might want to change this to $this->getDb().

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...
51 1
        $result->execute (array ($serieId));
52 1
        if ($post = $result->fetchObject ()) {
53 1
            return new Serie ($post);
54
        }
55
        return NULL;
56
    }
57
58 2
    public static function getAllSeries() {
59 2
        return Base::getEntryArrayWithBookNumber (self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array (), "Serie");
60
    }
61
62 22
    public static function getAllSeriesByQuery($query) {
63 22
        return Base::getEntryArrayWithBookNumber (self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array ('%' . $query . '%'), "Serie");
64
    }
65
}
66