/** * Top-level function used to bind WFN w to formatted string. * @param $w WellFormedName to bind * @return Formatted String */ public function bindToFS(WellFormedName $w) { // Initialize the output with the CPE v2.3 string prefix. $fs = "cpe:2.3:"; foreach (array("part", "vendor", "product", "version", "update", "edition", "language", "sw_edition", "target_sw", "target_hw", "other") as $a) { $v = $this->bindValueForFS($w->get($a)); $fs = $fs . $v; // add a colon except at the very end if (strpos($a, "other") === false) { $fs = $fs . ":"; } } return $fs; }
/** * Compares each attribute value pair in two Well Formed Names. * @param $source WellFormedName Source WFN * @param $target WellFormedName Target WFN * @return A array mapping attribute string to attribute value Relation */ public function compareWFNs(WellFormedName $source, WellFormedName $target) { $result = array(); $result["part"] = $this->compare($source->get("part"), $target->get("part")); $result["vendor"] = $this->compare($source->get("vendor"), $target->get("vendor")); $result["product"] = $this->compare($source->get("product"), $target->get("product")); $result["version"] = $this->compare($source->get("version"), $target->get("version")); $result["update"] = $this->compare($source->get("update"), $target->get("update")); $result["edition"] = $this->compare($source->get("edition"), $target->get("edition")); $result["language"] = $this->compare($source->get("language"), $target->get("language")); $result["sw_edition"] = $this->compare($source->get("sw_edition"), $target->get("sw_edition")); $result["target_sw"] = $this->compare($source->get("target_sw"), $target->get("target_sw")); $result["target_hw"] = $this->compare($source->get("target_hw"), $target->get("target_hw")); $result["other"] = $this->compare($source->get("other"), $target->get("other")); return $result; }