Skip to content

Commit

Permalink
Sanity check - make sure sniffs appears in the class name (ref #1451)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed May 9, 2017
1 parent a7d530c commit d429124
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Util/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,14 @@ public static function getSniffCode($sniffClass)
public static function cleanSniffClass($sniffClass)
{
$newName = strtolower($sniffClass);
$end = (strlen($newName) - strrpos($newName, '\sniffs\\') + 1);

$sniffPos = strrpos($newName, '\sniffs\\');
if ($sniffPos === false) {
// Nothing we can do as it isn't in a known format.
return $newName;
}

$end = (strlen($newName) - $sniffPos + 1);
$start = strrpos($newName, '\\', ($end * -1));
$newName = substr($newName, ($start + 1));
return $newName;
Expand Down

0 comments on commit d429124

Please sign in to comment.