in lib/php/libsdk/SDK/Config.php [255:315]
public static function getCurrentBranchData() : array
{/*{{{*/
$ret = array();
$branches = self::getKnownBranches();
$current_branch_name = self::getCurrentBranchName();
if (!array_key_exists($current_branch_name, $branches)) {
throw new Exception("Unknown branch '$current_branch_name'");
}
$cur_crt = Config::getCurrentCrtName();
if (count($branches[$current_branch_name]) > 1) {
if (NULL === $cur_crt) {
throw new Exception("More than one CRT is available for branch '$current_branch_name', pass one explicitly.");
}
$cur_crt_usable = false;
foreach (array_keys($branches[$current_branch_name]) as $crt) {
if ($cur_crt == $crt) {
$cur_crt_usable = true;
break;
}
}
if (!$cur_crt_usable) {
throw new Exception("The passed CRT '$cur_crt' doesn't match any available for branch '$current_branch_name'");
}
$data = $branches[$current_branch_name][$cur_crt];
} else {
/* Evaluate CRTs, to avoid ambiquity. */
$crt = key($branches[$current_branch_name]);
$data = $branches[$current_branch_name][$crt];
if ($crt != $cur_crt) {
throw new Exception("The passed CRT '$cur_crt' doesn't match any available for branch '$current_branch_name'");
}
}
$ret["name"] = $current_branch_name;
$ret["crt"] = $crt;
/* Last step, filter by arch and stability. */
foreach ($data as $d) {
if (self::getCurrentArchName() == $d["arch"]) {
if (self::getCurrentStabilityName() == $d["stability"]) {
$ret["arch"] = $d["arch"];
$ret["stability"] = $d["stability"];
}
}
}
if (!isset($ret["arch"]) || !$ret["arch"]) {
throw new Exception("Failed to find config with arch '" . self::getCurrentArchName() . "'");
}
if (!isset($ret["stability"]) || !$ret["stability"]) {
throw new Exception("Failed to find config with stability '" . self::getCurrentStabilityName() . "'");
}
if (!isset($ret["crt"]) || !$ret["crt"]) {
throw new Exception("Failed to find config with arch '" . self::getCurrentArchName() . "'");
}
return $ret;
}/*}}}*/