Differential D13531 Diff 32708 src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php
Show All 24 Lines | public static function newFromDictionary( | ||||
$obj = self::initializeNewUnitMessage($build_target); | $obj = self::initializeNewUnitMessage($build_target); | ||||
$spec = array( | $spec = array( | ||||
'engine' => 'optional string', | 'engine' => 'optional string', | ||||
'namespace' => 'optional string', | 'namespace' => 'optional string', | ||||
'name' => 'string', | 'name' => 'string', | ||||
'result' => 'string', | 'result' => 'string', | ||||
'duration' => 'optional float', | 'duration' => 'optional float|int', | ||||
'path' => 'optional string', | 'path' => 'optional string', | ||||
'coverage' => 'optional map<string, wild>', | 'coverage' => 'optional map<string, wild>', | ||||
); | ); | ||||
// We're just going to ignore extra keys for now, to make it easier to | // We're just going to ignore extra keys for now, to make it easier to | ||||
// add stuff here later on. | // add stuff here later on. | ||||
$dict = array_select_keys($dict, array_keys($spec)); | $dict = array_select_keys($dict, array_keys($spec)); | ||||
PhutilTypeSpec::checkMap($dict, $spec); | PhutilTypeSpec::checkMap($dict, $spec); | ||||
$obj->setEngine(idx($dict, 'engine', '')); | $obj->setEngine(idx($dict, 'engine', '')); | ||||
$obj->setNamespace(idx($dict, 'namespace', '')); | $obj->setNamespace(idx($dict, 'namespace', '')); | ||||
$obj->setName($dict['name']); | $obj->setName($dict['name']); | ||||
$obj->setResult($dict['result']); | $obj->setResult($dict['result']); | ||||
$obj->setDuration(idx($dict, 'duration')); | $obj->setDuration((float)idx($dict, 'duration')); | ||||
$path = idx($dict, 'path'); | $path = idx($dict, 'path'); | ||||
if (strlen($path)) { | if (strlen($path)) { | ||||
$obj->setProperty('path', $path); | $obj->setProperty('path', $path); | ||||
} | } | ||||
$coverage = idx($dict, 'coverage'); | $coverage = idx($dict, 'coverage'); | ||||
if ($coverage) { | if ($coverage) { | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |