seblucas /
cops
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 At Libitum <[email protected]> |
||
| 7 | */ |
||
| 8 | |||
| 9 | require_once('base.php'); |
||
| 10 | |||
| 11 | class Publisher extends Base { |
||
| 12 | const ALL_PUBLISHERS_ID = "cops:publishers"; |
||
| 13 | const PUBLISHERS_COLUMNS = "publishers.id as id, publishers.name as name, count(*) as count"; |
||
| 14 | const SQL_ALL_PUBLISHERS = "select {0} from publishers, books_publishers_link where publishers.id = publisher group by publishers.id, publishers.name order by publishers.name"; |
||
| 15 | const SQL_PUBLISHERS_FOR_SEARCH = "select {0} from publishers, books_publishers_link where publishers.id = publisher and upper (publishers.name) like ? group by publishers.id, publishers.name order by publishers.name"; |
||
| 16 | |||
| 17 | |||
| 18 | public $id; |
||
| 19 | public $name; |
||
| 20 | |||
| 21 | 12 | public function __construct($post) { |
|
| 22 | 12 | $this->id = $post->id; |
|
| 23 | 12 | $this->name = $post->name; |
|
| 24 | 12 | } |
|
| 25 | |||
| 26 | 10 | public function getUri () { |
|
| 27 | 10 | return "?page=".parent::PAGE_PUBLISHER_DETAIL."&id=$this->id"; |
|
| 28 | } |
||
| 29 | |||
| 30 | 7 | public function getEntryId () { |
|
| 31 | 7 | return self::ALL_PUBLISHERS_ID.":".$this->id; |
|
| 32 | } |
||
| 33 | |||
| 34 | 18 | public static function getCount() { |
|
| 35 | // str_format (localize("publishers.alphabetical", count(array)) |
||
| 36 | 18 | return parent::getCountGeneric ("publishers", self::ALL_PUBLISHERS_ID, parent::PAGE_ALL_PUBLISHERS); |
|
|
0 ignored issues
–
show
|
|||
| 37 | } |
||
| 38 | |||
| 39 | 5 | public static function getPublisherByBookId ($bookId) { |
|
| 40 | 5 | $result = parent::getDb ()->prepare('select publishers.id as id, name |
|
|
0 ignored issues
–
show
It seems like you call parent on a different method (
getDb() instead of getPublisherByBookId()). 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 Loading history...
|
|||
| 41 | from books_publishers_link, publishers |
||
| 42 | 5 | where publishers.id = publisher and book = ?'); |
|
| 43 | 5 | $result->execute (array ($bookId)); |
|
| 44 | 5 | if ($post = $result->fetchObject ()) { |
|
| 45 | 5 | return new Publisher ($post); |
|
| 46 | } |
||
| 47 | return NULL; |
||
| 48 | } |
||
| 49 | |||
| 50 | 1 | public static function getPublisherById ($publisherId) { |
|
| 51 | 1 | $result = parent::getDb ()->prepare('select id, name |
|
|
0 ignored issues
–
show
It seems like you call parent on a different method (
getDb() instead of getPublisherById()). 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 Loading history...
|
|||
| 52 | 1 | from publishers where id = ?'); |
|
| 53 | 1 | $result->execute (array ($publisherId)); |
|
| 54 | 1 | if ($post = $result->fetchObject ()) { |
|
| 55 | 1 | return new Publisher ($post); |
|
| 56 | } |
||
| 57 | return NULL; |
||
| 58 | } |
||
| 59 | |||
| 60 | 2 | public static function getAllPublishers() { |
|
| 61 | 2 | return Base::getEntryArrayWithBookNumber (self::SQL_ALL_PUBLISHERS, self::PUBLISHERS_COLUMNS, array (), "Publisher"); |
|
| 62 | } |
||
| 63 | |||
| 64 | 23 | public static function getAllPublishersByQuery($query) { |
|
| 65 | 23 | return Base::getEntryArrayWithBookNumber (self::SQL_PUBLISHERS_FOR_SEARCH, self::PUBLISHERS_COLUMNS, array ('%' . $query . '%'), "Publisher"); |
|
| 66 | } |
||
| 67 | } |
||
| 68 |
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:
The
getFirstName()method in theSoncalls the wrong method in the parent class.