You are here

function crumbs_Container_WeightMap::findBetterCandidateKey in Crumbs, the Breadcrumbs suite 7.2

Check if the candidates contain a key with better weight than the one given.

Parameters

string|null $bestKey:

int|null $bestWeight:

mixed[] $candidates: Format: $[$candidateKey] = $candidateValue

Return value

string|null The candidate key with the smallest weight, or NULL if none found.

1 call to crumbs_Container_WeightMap::findBetterCandidateKey()
crumbs_Container_WeightMap::findBestCandidateKey in lib/Container/WeightMap.php

File

lib/Container/WeightMap.php, line 121

Class

crumbs_Container_WeightMap
Can determine a weight for a rule key based on wildcard weights.

Code

function findBetterCandidateKey(&$bestKey, &$bestWeight, array $candidates) {
  foreach ($candidates as $key => $value) {
    $weight = $this
      ->valueAtKey($key);
    if ($weight === FALSE) {
      continue;
    }
    if (!isset($bestWeight) || $weight < $bestWeight) {
      $bestWeight = $weight;
      $bestKey = $key;
    }
  }
}