Skip to content

Commit 93e123f

Browse files
committed
fixed clear - if two classes begins with the same name
1 parent f60e987 commit 93e123f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/MabeEnum/Enum.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,12 @@ static public function get($value)
145145
final static function clear()
146146
{
147147
$class = get_called_class();
148-
$length = strlen($class);
149148

150149
// clear instantiated enums
150+
$prefix = $class . '.';
151+
$prefixLength = strlen($prefix);
151152
foreach (self::$instances as $id => $enum) {
152-
if (strncasecmp($class . '.', $id, $length) === 0) {
153+
if (strncasecmp($prefix, $id, $prefixLength) === 0) {
153154
unset(self::$instances[$id]);
154155
}
155156
}

0 commit comments

Comments
 (0)