Code Duplication    Length = 20-20 lines in 2 locations

class/utility.php 1 location

@@ 730-749 (lines=20) @@
727
     * @param  bool $optional
728
     * @return bool
729
     */
730
    public static function sf_gethandler($name, $optional = false)
731
    {
732
        static $handlers;
733
        $name = strtolower(trim($name));
734
        if (!isset($handlers[$name])) {
735
            if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/modules/smartfaq/class/' . $name . '.php')) {
736
                require_once $hnd_file;
737
            }
738
            $class = 'sf' . ucfirst($name) . 'Handler';
739
            if (class_exists($class)) {
740
                $handlers[$name] = new $class($GLOBALS['xoopsDB']);
741
            }
742
        }
743
        if (!$optional && !isset($handlers[$name])) {
744
            trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR);
745
        }
746
        $false = false;
747
748
        return isset($handlers[$name]) ? $handlers[$name] : $false;
749
    }
750
}
751

include/functions.php 1 location

@@ 590-609 (lines=20) @@
587
 * @param  bool $optional
588
 * @return bool
589
 */
590
function sf_gethandler($name, $optional = false)
591
{
592
    static $handlers;
593
    $name = strtolower(trim($name));
594
    if (!isset($handlers[$name])) {
595
        if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/modules/smartfaq/class/' . $name . '.php')) {
596
            require_once $hnd_file;
597
        }
598
        $class = 'sf' . ucfirst($name) . 'Handler';
599
        if (class_exists($class)) {
600
            $handlers[$name] = new $class($GLOBALS['xoopsDB']);
601
        }
602
    }
603
    if (!$optional && !isset($handlers[$name])) {
604
        trigger_error('Class <b>' . $class . '</b> does not exist<br>Handler Name: ' . $name, E_USER_ERROR);
605
    }
606
    $false = false;
607
608
    return isset($handlers[$name]) ? $handlers[$name] : $false;
609
}
610