Code Duplication    Length = 22-22 lines in 2 locations

lib/plugins/Normalizer/plugin.php 1 location

@@ 81-102 (lines=22) @@
78
        $this->opts = array_merge($defaults, $opts);
79
    }
80
81
    public function cmdPreprocess($cmd, &$args, $elfinder, $volume)
82
    {
83
        $opts = $this->getCurrentOpts($volume);
84
        if (! $opts['enable']) {
85
            return false;
86
        }
87
        $this->replaced[$cmd] = [];
88
        $key = (isset($this->keyMap[$cmd])) ? $this->keyMap[$cmd] : 'name';
89
90
        if (isset($args[$key])) {
91
            if (is_array($args[$key])) {
92
                foreach ($args[$key] as $i => $name) {
93
                    $this->replaced[$cmd][$name] = $args[$key][$i] = $this->normalize($name, $opts);
94
                }
95
            } else {
96
                $name = $args[$key];
97
                $this->replaced[$cmd][$name] = $args[$key] = $this->normalize($name, $opts);
98
            }
99
        }
100
101
        return true;
102
    }
103
104
    public function cmdPostprocess($cmd, &$result, $args, $elfinder)
105
    {

lib/plugins/Sanitizer/plugin.php 1 location

@@ 68-89 (lines=22) @@
65
        $this->opts = array_merge($defaults, $opts);
66
    }
67
68
    public function cmdPreprocess($cmd, &$args, $elfinder, $volume)
69
    {
70
        $opts = $this->getCurrentOpts($volume);
71
        if (! $opts['enable']) {
72
            return false;
73
        }
74
        $this->replaced[$cmd] = [];
75
        $key = (isset($this->keyMap[$cmd])) ? $this->keyMap[$cmd] : 'name';
76
77
        if (isset($args[$key])) {
78
            if (is_array($args[$key])) {
79
                foreach ($args[$key] as $i => $name) {
80
                    $this->replaced[$cmd][$name] = $args[$key][$i] = $this->sanitizeFileName($name, $opts);
81
                }
82
            } else {
83
                $name = $args[$key];
84
                $this->replaced[$cmd][$name] = $args[$key] = $this->sanitizeFileName($name, $opts);
85
            }
86
        }
87
88
        return true;
89
    }
90
91
    public function cmdPostprocess($cmd, &$result, $args, $elfinder)
92
    {