Completed
Push — xmfasserts ( b960a9...e3386a )
by Richard
05:27
created

XoopsFile::getHandler()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 12

Duplication

Lines 7
Ratio 43.75 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 2
nop 4
dl 7
loc 16
ccs 11
cts 11
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * XoopsFile
14
 *
15
 * File factory For XOOPS
16
 *
17
 * PHP 5.3
18
 *
19
 * @category  Xoops\Class\Cache\CacheApc
20
 * @package   CacheApc
21
 * @author    Taiwen Jiang <[email protected]>
22
 * @copyright 2013 XOOPS Project (http://xoops.org)
23
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
24
 * @version   $Id$
25
 * @link      http://xoops.org
26
 * @since     2.6.0
27
 */
28
class XoopsFile
29
{
30
    /**
31
     * XoopsFile::getHandler()
32
     *
33
     * @param string $name   name of file
34
     * @param string  $path   path file is in
35
     * @param boolean  $create create file if needed
36
     * @param integer  $mode   mode on file created
37
     *
38
     * @return XoopsFileHandler|XoopsFolderHandler|bool
39
     */
40 45
    public static function getHandler($name = 'file', $path = false, $create = false, $mode = null)
41
    {
42 45
        $handler = null;
0 ignored issues
show
Unused Code introduced by
$handler 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...
43 45
        $name = strtolower(trim($name));
44 45
        $class = 'Xoops' . ucfirst($name) . 'Handler';
45 45
        if (in_array($name, array('file', 'folder'))) {
46 45
            $handler = new $class($path, $create, $mode);
47 View Code Duplication
        } else {
48 1
            trigger_error(
49 1
                'Class ' . $class . ' not exist in File ' . __FILE__ . ' at Line ' . __LINE__,
50 1
                E_USER_WARNING
51
            );
52 1
            return false;
53
        }
54 45
        return $handler;
55
    }
56
}
57