Calculating an end point and a style definition

Automatic Cinema requires for the successful production of a story the material that should be shown at the end, a duration how long the story should be and a style definition, how the story should be told.
The «how» and the «what» is either defined directly by setting a distinctive value or by defining a set of parameters. For example, the movie clip with the id 5 could be the end of a story, or anything that has the keyword "car" in its description. Same for styles: It could be number 2, the definition of a style called "Thriller", or anything with the value "fast" for speed and "non-continuous" for spatial continuity.
So called parametric definitions are first converted to a distinctive id:

if ($this->end["type"] == "parametrical") 

$this->end["id"] = $this->_bestmatch($this->end["parameters"], $this->database_tables_names["material"], $this->target_material_parametrical_fieldnames);
if ($this->style["type"] == "parametrical")
$this->style["id"] = $this->_bestmatch($this->style["parameters"], $this->database_tables_names["style"], $this->target_styles_parametrical_fieldnames);