Piou-piou /
ribs-module-blog
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | namespace modules\blog\app\controller; |
||
| 3 | |||
| 4 | |||
| 5 | use core\App; |
||
| 6 | |||
| 7 | class Article { |
||
| 8 | |||
| 9 | |||
| 10 | //-------------------------- BUILDER ----------------------------------------------------------------------------// |
||
| 11 | public function __construct() { |
||
| 12 | |||
| 13 | } |
||
| 14 | //-------------------------- END BUILDER ----------------------------------------------------------------------------// |
||
| 15 | |||
| 16 | |||
| 17 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
||
| 18 | /** |
||
| 19 | * this function get last articles |
||
| 20 | */ |
||
| 21 | public function getLastArticle() { |
||
| 22 | $dbc = App::getDb(); |
||
| 23 | $nb_article = Blog::getArticleIndex(); |
||
| 24 | |||
| 25 | $query = $dbc->select()->from("_blog_article")->limit(0,$nb_article)->get(); |
||
| 26 | |||
| 27 | if ((is_array($query)) && (count($query) > 0)) { |
||
| 28 | $articles = []; |
||
| 29 | |||
| 30 | View Code Duplication | foreach ($query as $obj) { |
|
|
1 ignored issue
–
show
|
|||
| 31 | $articles[] = [ |
||
| 32 | "id_article" => $obj->ID_article, |
||
| 33 | "title" => $obj->title, |
||
| 34 | "url" => $obj->url, |
||
| 35 | "article" => $obj->article, |
||
| 36 | "publication_date" => $obj->publication_date |
||
| 37 | ]; |
||
| 38 | } |
||
| 39 | |||
| 40 | App::setValues(["blog" => $articles]); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | public function getArticle() { |
||
| 45 | $dbc = App::getDb(); |
||
| 46 | $param = Blog::$parametre_router; |
||
| 47 | |||
| 48 | $query = $dbc->select()->from("_blog_article") |
||
| 49 | ->where("ID_article", "=", $param, "OR") |
||
| 50 | ->where("url", "=", $param) |
||
| 51 | ->get(); |
||
| 52 | |||
| 53 | if ((is_array($query)) && (count($query) == 1)) { |
||
| 54 | View Code Duplication | foreach ($query as $obj) { |
|
|
1 ignored issue
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 55 | App::setValues(["blog" => [ |
||
| 56 | "id_article" => $obj->ID_article, |
||
| 57 | "title" => $obj->title, |
||
| 58 | "url" => $obj->url, |
||
| 59 | "article" => $obj->article, |
||
| 60 | "publication_date" => $obj->publication_date |
||
| 61 | ]]); |
||
| 62 | } |
||
| 63 | } |
||
| 64 | } |
||
| 65 | //-------------------------- END GETTER ----------------------------------------------------------------------------// |
||
| 66 | |||
| 67 | |||
| 68 | //-------------------------- SETTER ----------------------------------------------------------------------------// |
||
| 69 | //-------------------------- END SETTER ----------------------------------------------------------------------------// |
||
| 70 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.