Completed
Push — master ( a4e09c...825da9 )
by Michael
01:51
created

CategoryHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 33.33 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 9
loc 27
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A updateDateupdated() 9 9 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace Xoopsmodules\instruction;
2
3
// ааа
4
5
//if (!defined("XOOPS_ROOT_PATH")) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
6
//	die("XOOPS root path not defined");
7
//}
8
9
include_once $GLOBALS['xoops']->path('include/common.php');
10
11
include_once __DIR__ . '/../class/utility.php';
12
13
/**
14
 * Class CategoryHandler
15
 * @package Xoopsmodules\instruction
16
 */
17
class CategoryHandler extends \XoopsPersistableObjectHandler
18
{
19
    /**
20
     * @param null|mixed $db
21
     */
22
    public function __construct(\XoopsDatabase $db = null)
23
    {
24
        parent::__construct($db, 'instruction_cat', Category::class, 'cid', 'title');
25
    }
26
27
    // Обновление даты обновления категории
28
29
    /**
30
     * @param int  $cid
31
     * @param null|int $time
32
     * @return mixed
33
     */
34 View Code Duplication
    public function updateDateupdated($cid = 0, $time = null)
0 ignored issues
show
Duplication introduced by
This method 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...
35
    {
36
        // Если не передали время
37
        $time = null === $time ? time() : (int)$time;
38
        //
39
        $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid);
40
        //
41
        return $this->db->query($sql);
42
    }
43
}
44