Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12741819
WithCollection.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
556 B
Referenced Files
None
Subscribers
None
WithCollection.php
View Options
<?php
namespace
Keruald\OmniTools\Collections
;
use
OutOfRangeException
;
trait
WithCollection
{
abstract
function
count
()
:
int
;
abstract
function
toArray
()
:
array
;
public
function
first
()
:
mixed
{
foreach
(
$this
->
toArray
()
as
$item
)
{
return
$item
;
}
throw
new
OutOfRangeException
(
"The collection is empty."
);
}
public
function
firstOr
(
mixed
$default
)
:
mixed
{
return
match
(
$this
->
count
())
{
0
=>
$default
,
default
=>
$this
->
first
(),
};
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 16, 13:34 (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3153054
Default Alt Text
WithCollection.php (556 B)
Attached To
Mode
rKOT Keruald OmniTools
Attached
Detach File
Event Timeline
Log In to Comment