Skip to content

Commit 0519ff1

Browse files
authored
Added getFirst & getLast
1 parent ae54014 commit 0519ff1

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/Utils/BaseSet.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ public function count() : int
5151
{
5252
return \count($this->array);
5353
}
54+
55+
public function getFirst() : ?object
56+
{
57+
$key = \array_key_first($this->array);
58+
59+
return $key === null
60+
? null
61+
: $this->array[$key];
62+
}
63+
64+
public function getLast() : ?object
65+
{
66+
$key = \array_key_last($this->array);
67+
68+
return $key === null
69+
? null
70+
: $this->array[$key];
71+
}
5472

5573
public function offsetExists($offset) : bool
5674
{

0 commit comments

Comments
 (0)