Code Duplication    Length = 25-25 lines in 2 locations

Sniffs/PHP/NewFunctionParametersSniff.php 1 location

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

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