Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F56407029
TraversableUtilities.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
962 B
Referenced Files
None
Subscribers
None
TraversableUtilities.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\OmniTools\Collections
;
use
Countable
;
use
InvalidArgumentException
;
use
ResourceBundle
;
use
SimpleXMLElement
;
use
TypeError
;
class
TraversableUtilities
{
public
static
function
count
(
$countable
)
:
int
{
if
(
is_countable
(
$countable
))
{
return
count
(
$countable
);
}
if
(
$countable
===
null
||
$countable
===
false
)
{
return
0
;
}
throw
new
TypeError
;
}
public
static
function
first
(
iterable
$iterable
)
:
mixed
{
foreach
(
$iterable
as
$value
)
{
return
$value
;
}
throw
new
InvalidArgumentException
(
"Can't call first() on an empty iterable."
);
}
public
static
function
firstOr
(
iterable
$iterable
,
mixed
$defaultValue
=
null
)
:
mixed
{
foreach
(
$iterable
as
$value
)
{
return
$value
;
}
return
$defaultValue
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 7, 21:25 (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4227391
Default Alt Text
TraversableUtilities.php (962 B)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment