BookshopBookshop_langHandler::GetAllLang()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 5
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
//  ------------------------------------------------------------------------ //
3
//                      BOOKSHOP - MODULE FOR XOOPS 2                        //
4
//                  Copyright (c) 2007, 2008 Instant Zero                    //
5
//                     <http://www.instant-zero.com/>                        //
6
// ------------------------------------------------------------------------- //
7
//  This program is free software; you can redistribute it and/or modify     //
8
//  it under the terms of the GNU General Public License as published by     //
9
//  the Free Software Foundation; either version 2 of the License, or        //
10
//  (at your option) any later version.                                      //
11
//                                                                           //
12
//  You may not change or alter any portion of this comment or credits       //
13
//  of supporting developers from this source code or any supporting         //
14
//  source code which is considered copyrighted (c) material of the          //
15
//  original comment or credit authors.                                      //
16
//                                                                           //
17
//  This program is distributed in the hope that it will be useful,          //
18
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
19
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
20
//  GNU General Public License for more details.                             //
21
//                                                                           //
22
//  You should have received a copy of the GNU General Public License        //
23
//  along with this program; if not, write to the Free Software              //
24
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
25
//  ------------------------------------------------------------------------ //
26
27
defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
28
29
include_once XOOPS_ROOT_PATH . '/kernel/object.php';
30
if (!class_exists('Bookshop_XoopsPersistableObjectHandler')) {
31
    include_once XOOPS_ROOT_PATH . '/modules/bookshop/class/PersistableObjectHandler.php';
32
}
33
34
/**
35
 * Class bookshop_lang
36
 */
37 View Code Duplication
class bookshop_lang extends Bookshop_Object
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
38
{
39
    public function __construct()
40
    {
41
        $this->initVar('lang_id', XOBJ_DTYPE_INT, null, false);
42
        $this->initVar('lang_lang', XOBJ_DTYPE_TXTBOX, null, false);
43
    }
44
}
45
46
/**
47
 * Class BookshopBookshop_langHandler
48
 */
49 View Code Duplication
class BookshopBookshop_langHandler extends Bookshop_XoopsPersistableObjectHandler
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
50
{
51
    /**
52
     * @param $db
53
     */
54
    public function __construct($db)
55
    {    //                                             Table               Classe       Id
56
        parent::__construct($db, 'bookshop_lang', 'bookshop_lang', 'lang_id');
57
    }
58
59
    /**
60
     * Renvoie la liste de toutes les langues du module
61
     *
62
	 * @param integer $start Position de départ
63
	 * @param integer $limit Nombre total d'enregistrements à renvoyer
64
	 * @param string $order Champ sur lequel faire le tri
65
     * @param string  $order   Ordre du tri
66
	 * @param boolean $idaskey Indique si le tableau renvoyé doit avoir pour clé l'identifiant unique de l'enregistrement
67
     *
68
     * @return array tableau d'objets de type langues
69
     */
70
    public function GetAllLang($start = 0, $limit = 0, $sort = 'lang_lang', $order = 'ASC', $idaskey = true)
71
    {
72
        $critere = new Criteria('lang_id', 0, '<>');
73
        $critere->setLimit($limit);
74
        $critere->setStart($start);
75
        $critere->setSort($sort);
76
        $critere->setOrder($order);
77
        $tbl_categs = array();
0 ignored issues
show
Unused Code introduced by
$tbl_categs is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
78
        $tbl_categs = $this->getObjects($critere, $idaskey);
79
80
        return $tbl_categs;
81
    }
82
}
83