Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F13144250
TraversableUtilities.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
956 B
Referenced Files
None
Subscribers
None
TraversableUtilities.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\OmniTools\Collections
;
use
Countable
;
use
ResourceBundle
;
use
SimpleXMLElement
;
use
TypeError
;
class
TraversableUtilities
{
public
static
function
count
(
$countable
)
:
int
{
if
(
self
::
isCountable
(
$countable
))
{
return
count
(
$countable
);
}
if
(
$countable
===
null
||
$countable
===
false
)
{
return
0
;
}
throw
new
TypeError
;
}
public
static
function
isCountable
(
$countable
)
:
bool
{
if
(
function_exists
(
'is_countable'
))
{
// PHP 7.3 has is_countable
return
is_countable
(
$countable
);
}
// https://github.com/Ayesh/is_countable-polyfill/blob/master/src/is_countable.php
return
is_array
(
$countable
)
||
$countable
instanceof
Countable
||
$countable
instanceof
SimpleXMLElement
||
$countable
instanceof
ResourceBundle
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 21, 16:57 (11 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3148507
Default Alt Text
TraversableUtilities.php (956 B)
Attached To
Mode
rKOT Keruald OmniTools
Attached
Detach File
Event Timeline
Log In to Comment