Skip to content

Commit a9e5041

Browse files
committed
Simplify customization of ElementNameMinimalLength
1 parent 49413bf commit a9e5041

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

Inpsyde/Sniffs/CodeQuality/ElementNameMinimalLengthSniff.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ final class ElementNameMinimalLengthSniff implements Sniff
4848
'wp',
4949
];
5050

51+
/**
52+
* @var string[]
53+
*/
54+
public $additionalAllowedNames = [];
55+
5156
/**
5257
* @return int[]
5358
*/
@@ -108,10 +113,20 @@ private function shouldBeSkipped(
108113
*/
109114
private function isShortNameAllowed(string $variableName): bool
110115
{
111-
return in_array(
112-
strtolower($variableName),
113-
$this->allowedShortNames,
114-
true
115-
);
116+
$target = strtolower($variableName);
117+
118+
foreach ($this->allowedShortNames as $allowed) {
119+
if (strtolower($allowed) === $target) {
120+
return true;
121+
}
122+
}
123+
124+
foreach ($this->additionalAllowedNames as $allowed) {
125+
if (strtolower($allowed) === $target) {
126+
return true;
127+
}
128+
}
129+
130+
return false;
116131
}
117132
}

0 commit comments

Comments
 (0)