Code Duplication    Length = 36-36 lines in 2 locations

class/Utility.php 1 location

@@ 80-115 (lines=36) @@
77
         * - "/" in a string
78
         * - "&" in a string
79
        */
80
        public static function planetParseArguments(&$args_numeric, &$args, &$args_string)
81
        {
82
            $args_abb     = [
83
                'a' => 'article',
84
                'b' => 'blog',
85
                'c' => 'category',
86
                'l' => 'list',
87
                'o' => 'sort',
88
                's' => 'start',
89
                'u' => 'uid'
90
            ];
91
            $args         = [];
92
            $args_numeric = [];
93
            $args_string  = [];
94
            if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
95
                $vars = preg_split("/[\/|&]/", $matches[1]);
96
                $vars = array_map('trim', $vars);
97
                if (count($vars) > 0) {
98
                    foreach ($vars as $var) {
99
                        if (is_numeric($var)) {
100
                            $args_numeric[] = $var;
101
                        } elseif (false === strpos($var, '=')) {
102
                            if (is_numeric(substr($var, 1))) {
103
                                $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1);
104
                            } else {
105
                                $args_string[] = urldecode($var);
106
                            }
107
                        } else {
108
                            parse_str($var, $args);
109
                        }
110
                    }
111
                }
112
            }
113
114
            return (0 == count($args) + count($args_numeric) + count($args_string)) ? null : true;
115
        }
116
117
        /**
118
         * Function to parse class prefix

include/functions.php 1 location

@@ 73-108 (lines=36) @@
70
     * - "/" in a string
71
     * - "&" in a string
72
    */
73
    function planetParseArguments(&$args_numeric, &$args, &$args_string)
74
    {
75
        $args_abb     = [
76
            'a' => 'article',
77
            'b' => 'blog',
78
            'c' => 'category',
79
            'l' => 'list',
80
            'o' => 'sort',
81
            's' => 'start',
82
            'u' => 'uid'
83
        ];
84
        $args         = [];
85
        $args_numeric = [];
86
        $args_string  = [];
87
        if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
88
            $vars = preg_split("/[\/|&]/", $matches[1]);
89
            $vars = array_map('trim', $vars);
90
            if (count($vars) > 0) {
91
                foreach ($vars as $var) {
92
                    if (is_numeric($var)) {
93
                        $args_numeric[] = $var;
94
                    } elseif (false === strpos($var, '=')) {
95
                        if (is_numeric(substr($var, 1))) {
96
                            $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1);
97
                        } else {
98
                            $args_string[] = urldecode($var);
99
                        }
100
                    } else {
101
                        parse_str($var, $args);
102
                    }
103
                }
104
            }
105
        }
106
107
        return (0 == count($args) + count($args_numeric) + count($args_string)) ? null : true;
108
    }
109
110
    /**
111
     * Function to parse class prefix