1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 11:22:40 +01:00
phorge-phorge/src/applications/phid/storage/PhabricatorPHID.php

23 lines
483 B
PHP
Raw Normal View History

2011-01-23 06:09:13 +01:00
<?php
final class PhabricatorPHID extends Phobject {
2011-01-23 06:09:13 +01:00
public static function generateNewPHID($type, $subtype = null) {
2011-01-23 06:09:13 +01:00
if (!$type) {
throw new Exception(pht('Can not generate PHID with no type.'));
2011-01-23 06:09:13 +01:00
}
if ($subtype === null) {
$uniq_len = 20;
$type_str = "{$type}";
} else {
$uniq_len = 15;
$type_str = "{$type}-{$subtype}";
}
$uniq = Filesystem::readRandomCharacters($uniq_len);
return "PHID-{$type_str}-{$uniq}";
2011-01-23 06:09:13 +01:00
}
}