Skip to content

Commit f3275cf

Browse files
committed
coding style fixes
1 parent 6c47004 commit f3275cf

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Enum.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ final public static function getByOrdinal($ordinal)
222222
$class = get_called_class();
223223
$constants = self::detectConstants($class);
224224
$item = array_slice($constants, $ordinal, 1, true);
225-
if (!$item) {
225+
if (empty($item)) {
226226
throw new InvalidArgumentException(sprintf(
227227
'Invalid ordinal number, must between 0 and %s',
228228
count($constants) - 1
@@ -292,7 +292,7 @@ private static function detectConstants($class)
292292
$ambiguous[var_export($value, true)] = $names;
293293
}
294294
}
295-
if ($ambiguous) {
295+
if (!empty($ambiguous)) {
296296
throw new LogicException(
297297
'All possible values needs to be unique. The following are ambiguous: '
298298
. implode(', ', array_map(function ($names) use ($constants) {

tests/MabeEnumTest/EnumTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ public function testGetEnumerators()
111111
{
112112
$constants = EnumInheritance::getConstants();
113113
$enumerators = EnumInheritance::getEnumerators();
114+
$count = count($enumerators);
114115

115-
$this->assertSame(count($constants), count($enumerators));
116-
for ($i = 0; $i < count($enumerators); ++$i) {
116+
$this->assertSame(count($constants), $count);
117+
for ($i = 0; $i < $count; ++$i) {
117118
$this->assertArrayHasKey($i, $enumerators);
118119
$this->assertInstanceOf('MabeEnumTest\TestAsset\EnumInheritance', $enumerators[$i]);
119120

0 commit comments

Comments
 (0)