Code Duplication    Length = 25-25 lines in 2 locations

Sniffs/PHP/RemovedFunctionParametersSniff.php 1 location

@@ 146-170 (lines=25) @@
143
     *
144
     * @return void
145
     */
146
    protected function addError($phpcsFile, $stackPtr, $function, $parameterLocation)
147
    {
148
        $error = '';
149
150
        $this->error = false;
151
        foreach ($this->removedFunctionParameters[$function][$parameterLocation] as $version => $present) {
152
            if ($version != 'name' && $this->supportsAbove($version)) {
153
                if ($present === false) {
154
                    $this->error = true;
155
                    $error .= 'in PHP version ' . $version . ' or later';
156
                }
157
            }
158
        }
159
        
160
        if (strlen($error) > 0) {
161
            $error = 'The function ' . $function . ' does not have a parameter ' . $this->removedFunctionParameters[$function][$parameterLocation]['name'] . ' ' . $error;
162
163
            if ($this->error === true) {
164
                $phpcsFile->addError($error, $stackPtr);
165
            } else {
166
                $phpcsFile->addWarning($error, $stackPtr);
167
            }
168
        }
169
170
    }//end addError()
171
172
}//end class
173

Sniffs/PHP/NewFunctionParametersSniff.php 1 location

@@ 157-181 (lines=25) @@
154
     *
155
     * @return void
156
     */
157
    protected function addError($phpcsFile, $stackPtr, $function, $parameterLocation)
158
    {
159
        $error = '';
160
161
        $this->error = false;
162
        foreach ($this->newFunctionParameters[$function][$parameterLocation] as $version => $present) {
163
            if ($version != 'name' && $this->supportsBelow($version)) {
164
                if ($present === false) {
165
                    $this->error = true;
166
                    $error .= 'in PHP version ' . $version . ' or earlier';
167
                }
168
            }
169
        }
170
        
171
        if (strlen($error) > 0) {
172
            $error = 'The function ' . $function . ' does not have a parameter ' . $this->newFunctionParameters[$function][$parameterLocation]['name'] . ' ' . $error;
173
174
            if ($this->error === true) {
175
                $phpcsFile->addError($error, $stackPtr);
176
            } else {
177
                $phpcsFile->addWarning($error, $stackPtr);
178
            }
179
        }
180
181
    }//end addError()
182
183
}//end class
184