Complex classes like Book often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Book, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
56 | class Book extends Base { |
||
57 | const ALL_BOOKS_UUID = "urn:uuid"; |
||
58 | const ALL_BOOKS_ID = "cops:books"; |
||
59 | const ALL_RECENT_BOOKS_ID = "cops:recentbooks"; |
||
60 | const BOOK_COLUMNS = BOOK_COLUMNS; |
||
61 | |||
62 | const SQL_BOOKS_LEFT_JOIN = SQL_BOOKS_LEFT_JOIN; |
||
63 | const SQL_BOOKS_ALL = SQL_BOOKS_ALL; |
||
64 | const SQL_BOOKS_BY_PUBLISHER = SQL_BOOKS_BY_PUBLISHER; |
||
65 | const SQL_BOOKS_BY_FIRST_LETTER = SQL_BOOKS_BY_FIRST_LETTER; |
||
66 | const SQL_BOOKS_BY_AUTHOR = SQL_BOOKS_BY_AUTHOR; |
||
67 | const SQL_BOOKS_BY_SERIE = SQL_BOOKS_BY_SERIE; |
||
68 | const SQL_BOOKS_BY_TAG = SQL_BOOKS_BY_TAG; |
||
69 | const SQL_BOOKS_BY_LANGUAGE = SQL_BOOKS_BY_LANGUAGE; |
||
70 | const SQL_BOOKS_BY_CUSTOM = SQL_BOOKS_BY_CUSTOM; |
||
71 | const SQL_BOOKS_QUERY = SQL_BOOKS_QUERY; |
||
72 | const SQL_BOOKS_RECENT = SQL_BOOKS_RECENT; |
||
73 | const SQL_BOOKS_BY_RATING = SQL_BOOKS_BY_RATING; |
||
74 | const SQL_BOOKS_FIRST_LETTERS = SQL_BOOKS_FIRST_LETTERS; |
||
75 | |||
76 | const BAD_SEARCH = "QQQQQ"; |
||
77 | |||
78 | public $id; |
||
79 | public $title; |
||
80 | public $timestamp; |
||
81 | public $pubdate; |
||
82 | public $path; |
||
83 | public $uuid; |
||
84 | public $hasCover; |
||
85 | public $relativePath; |
||
86 | public $seriesIndex; |
||
87 | public $comment; |
||
88 | public $rating; |
||
89 | public $datas = NULL; |
||
90 | public $authors = NULL; |
||
91 | public $publisher = NULL; |
||
92 | public $serie = NULL; |
||
93 | 69 | public $tags = NULL; |
|
94 | 69 | public $languages = NULL; |
|
95 | 69 | public $format = array (); |
|
96 | 69 | ||
97 | 69 | ||
98 | 69 | public function __construct($line) { |
|
99 | 69 | $this->id = $line->id; |
|
100 | 69 | $this->title = $line->title; |
|
101 | 69 | $this->timestamp = strtotime ($line->timestamp); |
|
102 | 69 | $this->pubdate = strtotime ($line->pubdate); |
|
103 | 69 | $this->path = Base::getDbDirectory () . $line->path; |
|
104 | 69 | $this->relativePath = $line->path; |
|
105 | $this->seriesIndex = $line->series_index; |
||
106 | 41 | $this->comment = $line->comment; |
|
107 | 41 | $this->uuid = $line->uuid; |
|
108 | 69 | $this->hasCover = $line->has_cover; |
|
109 | 69 | if (!file_exists ($this->getFilePath ("jpg"))) { |
|
110 | // double check |
||
111 | 40 | $this->hasCover = 0; |
|
112 | 40 | } |
|
113 | $this->rating = $line->rating; |
||
114 | } |
||
115 | 4 | ||
116 | 4 | public function getEntryId () { |
|
117 | return self::ALL_BOOKS_UUID.":".$this->uuid; |
||
118 | } |
||
119 | 3 | ||
120 | 3 | public static function getEntryIdByLetter ($startingLetter) { |
|
121 | return self::ALL_BOOKS_ID.":letter:".$startingLetter; |
||
122 | } |
||
123 | 3 | ||
124 | 3 | public function getUri () { |
|
125 | 3 | return "?page=".parent::PAGE_BOOK_DETAIL."&id=$this->id"; |
|
126 | 3 | } |
|
127 | |||
128 | public function getDetailUrl () { |
||
129 | 41 | $urlParam = $this->getUri (); |
|
130 | 41 | if (!is_null (GetUrlParam (DB))) { |
|
131 | $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); |
||
132 | $urlParam = addURLParameter ($urlParam, VL, GetUrlParam (VL, 0)); |
||
133 | } |
||
134 | return 'index.php' . $urlParam; |
||
135 | 46 | } |
|
136 | 46 | ||
137 | 46 | public function getTitle () { |
|
138 | 46 | return $this->title; |
|
139 | 46 | } |
|
140 | |||
141 | /* Other class (author, series, tag, ...) initialization and accessors */ |
||
142 | |||
143 | public function getAuthors () { |
||
144 | if (is_null ($this->authors)) { |
||
145 | $this->authors = Author::getAuthorByBookId ($this->id); |
||
146 | } |
||
147 | return $this->authors; |
||
148 | } |
||
149 | |||
150 | 4 | public function getAuthorsName () { |
|
151 | 4 | return implode (", ", array_map (function ($author) { return $author->name; }, $this->getAuthors ())); |
|
152 | 4 | } |
|
153 | 4 | ||
154 | 4 | public function getAuthorsSort () { |
|
155 | return implode (", ", array_map (function ($author) { return $author->sort; }, $this->getAuthors ())); |
||
156 | } |
||
157 | 45 | ||
158 | 45 | public function getPublisher () { |
|
159 | 45 | if (is_null ($this->publisher)) { |
|
160 | 45 | $this->publisher = Publisher::getPublisherByBookId ($this->id); |
|
161 | 45 | } |
|
162 | return $this->publisher; |
||
163 | } |
||
164 | 9 | ||
165 | 9 | public function getSerie () { |
|
166 | 9 | if (is_null ($this->serie)) { |
|
167 | $this->serie = Serie::getSerieByBookId ($this->id); |
||
168 | } |
||
169 | return $this->serie; |
||
170 | 9 | } |
|
171 | 9 | ||
172 | 9 | public function getLanguages () { |
|
173 | $lang = array (); |
||
174 | 9 | $result = parent::getDb ()->prepare('select languages.lang_code |
|
|
|||
175 | 9 | from books_languages_link, languages |
|
176 | 9 | where books_languages_link.lang_code = languages.id |
|
177 | and book = ? |
||
178 | order by item_order'); |
||
179 | 9 | $result->execute (array ($this->id)); |
|
180 | 9 | while ($post = $result->fetchObject ()) |
|
181 | 9 | { |
|
182 | array_push ($lang, Language::getLanguageString($post->lang_code)); |
||
183 | 9 | } |
|
184 | return implode (", ", $lang); |
||
185 | } |
||
186 | |||
187 | 9 | public function getTags () { |
|
188 | 9 | if (is_null ($this->tags)) { |
|
189 | 9 | $this->tags = array (); |
|
190 | |||
191 | 9 | $result = parent::getDb ()->prepare('select tags.id as id, name |
|
192 | 9 | from books_tags_link, tags |
|
193 | 9 | where tag = tags.id |
|
194 | 9 | and book = ? |
|
195 | order by name'); |
||
196 | $result->execute (array ($this->id)); |
||
197 | while ($post = $result->fetchObject ()) |
||
198 | { |
||
199 | array_push ($this->tags, new Tag ($post)); |
||
200 | } |
||
201 | 59 | } |
|
202 | return $this->tags; |
||
203 | 59 | } |
|
204 | 59 | ||
205 | 59 | public function getTagsName () { |
|
206 | 59 | return implode (", ", array_map (function ($tag) { return $tag->name; }, $this->getTags ())); |
|
207 | } |
||
208 | |||
209 | public function getDatas () |
||
210 | { |
||
211 | 56 | if (is_null ($this->datas)) { |
|
212 | 56 | $this->datas = Data::getDataByBook ($this); |
|
213 | 56 | } |
|
214 | return $this->datas; |
||
215 | 3 | } |
|
216 | 3 | ||
217 | 1 | /* End of other class (author, series, tag, ...) initialization and accessors */ |
|
218 | 1 | ||
219 | 1 | public static function getFilterString () { |
|
220 | $filter = getURLParam ("tag", NULL); |
||
221 | 3 | if (empty ($filter)) return ""; |
|
222 | |||
223 | 3 | $exists = true; |
|
224 | 1 | if (preg_match ("/^!(.*)$/", $filter, $matches)) { |
|
225 | 1 | $exists = false; |
|
226 | $filter = $matches[1]; |
||
227 | 3 | } |
|
228 | |||
229 | $result = "exists (select null from books_tags_link, tags where books_tags_link.book = books.id and books_tags_link.tag = tags.id and tags.name = '" . $filter . "')"; |
||
230 | 4 | ||
231 | if (!$exists) { |
||
232 | 4 | $result = "not " . $result; |
|
233 | 4 | } |
|
234 | 4 | ||
235 | 4 | return "and " . $result; |
|
236 | 4 | } |
|
237 | 4 | ||
238 | 4 | public function GetMostInterestingDataToSendToKindle () |
|
239 | 4 | { |
|
240 | 4 | $bestFormatForKindle = array ("EPUB", "PDF", "AZW3", "MOBI"); |
|
241 | 4 | $bestRank = -1; |
|
242 | 4 | $bestData = NULL; |
|
243 | foreach ($this->getDatas () as $data) { |
||
244 | $key = array_search ($data->format, $bestFormatForKindle); |
||
245 | 3 | if ($key !== false && $key > $bestRank) { |
|
246 | $bestRank = $key; |
||
247 | $bestData = $data; |
||
248 | 3 | } |
|
249 | 3 | } |
|
250 | 3 | return $bestData; |
|
251 | } |
||
252 | |||
253 | 7 | public function getDataById ($idData) |
|
254 | 7 | { |
|
255 | 2 | $reduced = array_filter ($this->getDatas (), function ($data) use ($idData) { |
|
256 | return $data->id == $idData; |
||
257 | 5 | }); |
|
258 | 5 | return reset ($reduced); |
|
259 | 5 | } |
|
260 | 5 | ||
261 | 5 | public function getRating () { |
|
262 | 3 | if (is_null ($this->rating) || $this->rating == 0) { |
|
263 | 3 | return ""; |
|
264 | 5 | } |
|
265 | $retour = ""; |
||
266 | for ($i = 0; $i < $this->rating / 2; $i++) { |
||
267 | 8 | $retour .= "★"; |
|
268 | 8 | } |
|
269 | for ($i = 0; $i < 5 - $this->rating / 2; $i++) { |
||
270 | $retour .= "☆"; |
||
271 | } |
||
272 | 8 | return $retour; |
|
273 | } |
||
274 | |||
275 | public function getPubDate () { |
||
276 | 41 | if (is_null ($this->pubdate) || ($this->pubdate <= -58979923200)) { |
|
277 | 41 | return ""; |
|
278 | 41 | } |
|
279 | 41 | else { |
|
280 | 36 | return date ("Y", $this->pubdate); |
|
281 | 36 | } |
|
282 | 41 | } |
|
283 | 41 | ||
284 | 35 | public function getComment ($withSerie = true) { |
|
285 | $addition = ""; |
||
286 | $se = $this->getSerie (); |
||
287 | if (!is_null ($se) && $withSerie) { |
||
288 | 29 | $addition = $addition . "<strong>" . localize("content.series") . "</strong>" . str_format (localize ("content.series.data"), $this->seriesIndex, htmlspecialchars ($se->name)) . "<br />\n"; |
|
289 | } |
||
290 | if (preg_match ("/<\/(div|p|a|span)>/", $this->comment)) |
||
291 | { |
||
292 | return $addition . html2xhtml ($this->comment); |
||
293 | 11 | } |
|
294 | 11 | else |
|
295 | 11 | { |
|
296 | 11 | return $addition . htmlspecialchars ($this->comment); |
|
297 | } |
||
298 | } |
||
299 | 69 | ||
300 | public function getDataFormat ($format) { |
||
301 | 69 | $reduced = array_filter ($this->getDatas (), function ($data) use ($format) { |
|
302 | 69 | return $data->format == $format; |
|
303 | 69 | }); |
|
304 | 69 | return reset ($reduced); |
|
305 | } |
||
306 | |||
307 | 2 | public function getFilePath ($extension, $idData = NULL, $relative = false) |
|
308 | 2 | { |
|
309 | 2 | if ($extension == "jpg") |
|
310 | { |
||
311 | $file = "cover.jpg"; |
||
312 | } |
||
313 | 69 | else |
|
314 | 3 | { |
|
315 | $data = $this->getDataById ($idData); |
||
316 | if (!$data) return NULL; |
||
317 | $file = $data->name . "." . strtolower ($data->format); |
||
318 | 69 | } |
|
319 | |||
320 | if ($relative) |
||
321 | { |
||
322 | return $this->relativePath."/".$file; |
||
323 | } |
||
324 | else |
||
325 | { |
||
326 | return $this->path."/".$file; |
||
327 | } |
||
328 | } |
||
329 | |||
330 | public function getUpdatedEpub ($idData) |
||
331 | { |
||
332 | global $config; |
||
333 | $data = $this->getDataById ($idData); |
||
334 | |||
335 | try |
||
336 | { |
||
337 | $epub = new EPub ($data->getLocalPath ()); |
||
338 | |||
339 | $epub->Title ($this->title); |
||
340 | $authorArray = array (); |
||
341 | foreach ($this->getAuthors() as $author) { |
||
342 | $authorArray [$author->sort] = $author->name; |
||
343 | } |
||
344 | $epub->Authors ($authorArray); |
||
345 | $epub->Language ($this->getLanguages ()); |
||
346 | $epub->Description ($this->getComment (false)); |
||
347 | $epub->Subjects ($this->getTagsName ()); |
||
348 | $epub->Cover2 ($this->getFilePath ("jpg"), "image/jpeg"); |
||
349 | $epub->Calibre ($this->uuid); |
||
350 | $se = $this->getSerie (); |
||
351 | if (!is_null ($se)) { |
||
352 | $epub->Serie ($se->name); |
||
353 | $epub->SerieIndex ($this->seriesIndex); |
||
354 | } |
||
355 | if ($config['cops_provide_kepub'] == "1" && preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) { |
||
356 | $epub->updateForKepub (); |
||
357 | } |
||
358 | 3 | $epub->download ($data->getUpdatedFilenameEpub ()); |
|
359 | 3 | } |
|
360 | 1 | catch (Exception $e) |
|
361 | { |
||
362 | echo "Exception : " . $e->getMessage(); |
||
363 | 3 | } |
|
364 | } |
||
365 | 3 | ||
366 | 3 | public function getThumbnail ($width, $height, $outputfile = NULL) { |
|
367 | 3 | if (is_null ($width) && is_null ($height)) { |
|
368 | return false; |
||
369 | 3 | } |
|
370 | 2 | ||
371 | 2 | $file = $this->getFilePath ("jpg"); |
|
372 | 1 | // get image size |
|
373 | 1 | if ($size = GetImageSize($file)) { |
|
374 | 2 | $w = $size[0]; |
|
375 | 2 | $h = $size[1]; |
|
376 | 1 | //set new size |
|
377 | if (!is_null ($width)) { |
||
378 | 2 | $nw = $width; |
|
379 | if ($nw >= $w) { return false; } |
||
380 | $nh = ($nw*$h)/$w; |
||
381 | } else { |
||
382 | $nh = $height; |
||
383 | 2 | if ($nh >= $h) { return false; } |
|
384 | 2 | $nw = ($nh*$w)/$h; |
|
385 | 2 | } |
|
386 | 2 | } else { |
|
387 | 2 | return false; |
|
388 | 2 | } |
|
389 | |||
390 | 2 | //draw the image |
|
391 | $src_img = imagecreatefromjpeg($file); |
||
392 | $dst_img = imagecreatetruecolor($nw,$nh); |
||
393 | 42 | imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h);//resizing the image |
|
394 | imagejpeg($dst_img,$outputfile,80); |
||
395 | 42 | imagedestroy($src_img); |
|
396 | imagedestroy($dst_img); |
||
397 | 42 | ||
398 | 42 | return true; |
|
399 | 18 | } |
|
400 | |||
401 | 18 | public function getLinkArray () |
|
402 | 18 | { |
|
403 | $linkArray = array(); |
||
404 | 42 | ||
405 | if ($this->hasCover) |
||
406 | 42 | { |
|
407 | 42 | array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)); |
|
408 | 42 | ||
409 | 42 | array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL)); |
|
410 | 42 | } |
|
411 | |||
412 | 42 | foreach ($this->getDatas () as $data) |
|
413 | 42 | { |
|
414 | 42 | if ($data->isKnownType ()) |
|
415 | { |
||
416 | 42 | array_push ($linkArray, $data->getDataLink (Link::OPDS_ACQUISITION_TYPE, $data->format)); |
|
417 | 42 | } |
|
418 | 39 | } |
|
419 | 39 | ||
420 | foreach ($this->getAuthors () as $author) { |
||
421 | 42 | array_push ($linkArray, new LinkNavigation ($author->getUri (), "related", str_format (localize ("bookentry.author"), localize ("splitByLetter.book.other"), $author->name))); |
|
422 | } |
||
423 | |||
424 | $serie = $this->getSerie (); |
||
425 | 39 | if (!is_null ($serie)) { |
|
426 | 39 | array_push ($linkArray, new LinkNavigation ($serie->getUri (), "related", str_format (localize ("content.series.data"), $this->seriesIndex, $serie->name))); |
|
427 | 39 | } |
|
428 | 39 | ||
429 | return $linkArray; |
||
430 | } |
||
431 | 3 | ||
432 | 3 | ||
433 | public function getEntry () { |
||
434 | return new EntryBook ($this->getTitle (), $this->getEntryId (), |
||
435 | 10 | $this->getComment (), "text/html", |
|
436 | 10 | $this->getLinkArray (), $this); |
|
437 | 10 | } |
|
438 | 10 | ||
439 | 10 | public static function getBookCount($database = NULL, $virtualLib = NULL) { |
|
440 | 10 | return parent::executeFilteredQuerySingle('select count(*) from ({0}) as filter', $database, $virtualLib); |
|
441 | 10 | } |
|
442 | 10 | ||
443 | 10 | public static function getCount() { |
|
444 | 10 | global $config; |
|
445 | 10 | $nBooks = self::getBookCount(); |
|
446 | 10 | $result = array(); |
|
447 | 10 | $entry = new Entry (localize ("allbooks.title"), |
|
448 | 10 | self::ALL_BOOKS_ID, |
|
449 | 10 | str_format (localize ("allbooks.alphabetical", $nBooks), $nBooks), "text", |
|
450 | 10 | array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS)), "", $nBooks); |
|
451 | 10 | array_push ($result, $entry); |
|
452 | if ($config['cops_recentbooks_limit'] > 0) { |
||
453 | $entry = new Entry (localize ("recent.title"), |
||
454 | 8 | self::ALL_RECENT_BOOKS_ID, |
|
455 | 8 | str_format (localize ("recent.list"), $config['cops_recentbooks_limit']), "text", |
|
456 | array ( new LinkNavigation ("?page=".parent::PAGE_ALL_RECENT_BOOKS)), "", $config['cops_recentbooks_limit']); |
||
457 | array_push ($result, $entry); |
||
458 | 1 | } |
|
459 | 1 | return $result; |
|
460 | } |
||
461 | |||
462 | 2 | public static function getBooksByAuthor($authorId, $n) { |
|
463 | 2 | return self::getEntryArray (self::SQL_BOOKS_BY_AUTHOR, array ($authorId), $n); |
|
464 | } |
||
465 | |||
466 | 2 | public static function getBooksByRating($ratingId, $n) { |
|
467 | 2 | return self::getEntryArray (self::SQL_BOOKS_BY_RATING, array ($ratingId), $n); |
|
468 | } |
||
469 | |||
470 | 2 | public static function getBooksByPublisher($publisherId, $n) { |
|
471 | 2 | return self::getEntryArray (self::SQL_BOOKS_BY_PUBLISHER, array ($publisherId), $n); |
|
472 | } |
||
473 | |||
474 | 2 | public static function getBooksBySeries($serieId, $n) { |
|
475 | 2 | return self::getEntryArray (self::SQL_BOOKS_BY_SERIE, array ($serieId), $n); |
|
476 | } |
||
477 | |||
478 | 3 | public static function getBooksByTag($tagId, $n) { |
|
479 | 3 | return self::getEntryArray (self::SQL_BOOKS_BY_TAG, array ($tagId), $n); |
|
480 | 3 | } |
|
481 | |||
482 | public static function getBooksByLanguage($languageId, $n) { |
||
483 | 30 | return self::getEntryArray (self::SQL_BOOKS_BY_LANGUAGE, array ($languageId), $n); |
|
484 | 30 | } |
|
485 | 30 | ||
486 | 30 | public static function getBooksByCustom($customId, $id, $n) { |
|
487 | 30 | $query = str_format (self::SQL_BOOKS_BY_CUSTOM, "{0}", CustomColumn::getTableLinkName ($customId), CustomColumn::getTableLinkColumn ($customId)); |
|
488 | 30 | return self::getEntryArray ($query, array ($id), $n); |
|
489 | } |
||
490 | 29 | ||
491 | 29 | public static function getBookById($bookId) { |
|
492 | $result = parent::getDb ()->prepare('select ' . self::BOOK_COLUMNS . ' |
||
493 | 1 | from books ' . self::SQL_BOOKS_LEFT_JOIN . ' |
|
494 | where books.id = ?'); |
||
495 | $result->execute (array ($bookId)); |
||
496 | 1 | while ($post = $result->fetchObject ()) |
|
497 | 1 | { |
|
498 | 1 | $book = new Book ($post); |
|
499 | 1 | return $book; |
|
500 | 1 | } |
|
501 | 1 | return NULL; |
|
502 | } |
||
503 | 1 | ||
504 | 1 | public static function getBookByDataId($dataId) { |
|
505 | 1 | $result = parent::getDb ()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format |
|
506 | 1 | from data, books ' . self::SQL_BOOKS_LEFT_JOIN . ' |
|
507 | 1 | where data.book = books.id and data.id = ?'); |
|
508 | $result->execute (array ($dataId)); |
||
509 | while ($post = $result->fetchObject ()) |
||
510 | { |
||
511 | $book = new Book ($post); |
||
512 | 2 | $data = new Data ($post, $book); |
|
513 | 2 | $data->id = $dataId; |
|
514 | 2 | $book->datas = array ($data); |
|
515 | 2 | return $book; |
|
516 | 2 | } |
|
517 | 2 | return NULL; |
|
518 | 2 | } |
|
519 | 2 | ||
520 | 2 | public static function getBooksByQuery($query, $n, $database = NULL, $virtualLib = NULL, $numberPerPage = NULL) { |
|
521 | 2 | $i = 0; |
|
522 | $critArray = array (); |
||
523 | foreach (array (PageQueryResult::SCOPE_AUTHOR, |
||
524 | PageQueryResult::SCOPE_TAG, |
||
525 | 2 | PageQueryResult::SCOPE_SERIES, |
|
526 | PageQueryResult::SCOPE_PUBLISHER, |
||
527 | PageQueryResult::SCOPE_BOOK) as $key) { |
||
528 | 2 | if (in_array($key, getCurrentOption ('ignored_categories')) || |
|
529 | (!array_key_exists ($key, $query) && !array_key_exists ("all", $query))) { |
||
530 | $critArray [$i] = self::BAD_SEARCH; |
||
531 | 2 | } |
|
532 | 2 | else { |
|
533 | 2 | if (array_key_exists ($key, $query)) { |
|
534 | $critArray [$i] = $query [$key]; |
||
535 | } else { |
||
536 | 1 | $critArray [$i] = $query ["all"]; |
|
537 | 1 | } |
|
538 | 1 | } |
|
539 | $i++; |
||
540 | } |
||
541 | 3 | return self::getEntryArray (self::SQL_BOOKS_QUERY, $critArray, $n, $database, $virtualLib, $numberPerPage); |
|
542 | 3 | } |
|
543 | |||
544 | public static function getBooks($n) { |
||
545 | 3 | list ($entryArray, $totalNumber) = self::getEntryArray (self::SQL_BOOKS_ALL , array (), $n); |
|
546 | 3 | return array ($entryArray, $totalNumber); |
|
547 | 3 | } |
|
548 | |||
549 | 3 | public static function getAllBooks() { |
|
550 | 3 | list (, $result) = parent::executeFilteredQuery(self::SQL_BOOKS_FIRST_LETTERS, array (), -1); |
|
551 | 3 | $entryArray = array(); |
|
552 | 3 | while ($post = $result->fetchObject ()) |
|
553 | 3 | { |
|
554 | array_push ($entryArray, new Entry ($post->title, Book::getEntryIdByLetter ($post->title), |
||
555 | str_format (localize("bookword", $post->count), $post->count), "text", |
||
556 | 25 | array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS_LETTER."&id=". rawurlencode ($post->title))), "", $post->count)); |
|
557 | 25 | } |
|
558 | return $entryArray; |
||
559 | } |
||
560 | 53 | ||
561 | 53 | public static function getBooksByStartingLetter($letter, $n, $database = NULL, $virtualLib = NULL, $numberPerPage = NULL) { |
|
564 | |||
565 | 39 | public static function getEntryArray ($query, $params, $n, $database = NULL, $virtualLib = NULL, $numberPerPage = NULL) { |
|
576 | |||
577 | |||
578 | public static function getAllRecentBooks() { |
||
583 | |||
584 | } |
||
585 |
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 theSon
calls the wrong method in the parent class.