Skip to content

Commit e89cb1f

Browse files
committed
isEmpty method
1 parent b15d342 commit e89cb1f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Utils/ArrayObject.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,12 @@ public function count()
187187
{
188188
return count($this->array);
189189
}
190+
191+
/**
192+
* @return bool
193+
*/
194+
public function isEmpty()
195+
{
196+
return $this->array === [];
197+
}
190198
}

test/Util/ArrayObjectTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,13 @@ public function testSet()
130130
$this->assertNotSame($new, $arrayObject);
131131
$this->assertSame(['one' => 1, 'two' => 2, 'three' => 4], $new->getArrayCopy());
132132
}
133+
134+
public function testIsEmpty()
135+
{
136+
$arrayObject = new ArrayObject([1, 2, 3]);
137+
self::assertFalse($arrayObject->isEmpty());
138+
139+
$arrayObject = new ArrayObject;
140+
self::assertTrue($arrayObject->isEmpty());
141+
}
133142
}

0 commit comments

Comments
 (0)