Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2894384
utils.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
893 B
Referenced Files
None
Subscribers
None
utils.php
View Options
<?php
/**
* Look up the type of a PHID. Returns
* PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN if it fails to look up the type
*
* @param phid $phid Anything.
* @return string A value from PhabricatorPHIDConstants (ideally)
*/
function
phid_get_type
(
$phid
)
{
$matches
=
null
;
if
(
is_string
(
$phid
)
&&
preg_match
(
'/^PHID-([^-]{4})-/'
,
$phid
,
$matches
)
)
{
return
$matches
[
1
]
;
}
return
PhabricatorPHIDConstants
::
PHID_TYPE_UNKNOWN
;
}
/**
* Group a list of phids by type.
*
* @param $phids Array of phids
* @return map of phid type => list of phids
*/
function
phid_group_by_type
(
$phids
)
{
$result
=
array
(
)
;
foreach
(
$phids
as
$phid
)
{
$type
=
phid_get_type
(
$phid
)
;
$result
[
$type
]
[
]
=
$phid
;
}
return
$result
;
}
function
phid_get_subtype
(
$phid
)
{
if
(
isset
(
$phid
[
14
]
)
&&
(
$phid
[
14
]
==
'-'
)
)
{
return
substr
(
$phid
,
10
,
4
)
;
}
return
null
;
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 19:49 (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1110020
Default Alt Text
utils.php (893 B)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment