public static function matchWildcard($wildcard_pattern, $haystack) { $regex = str_replace(["\\*", "\\?"], ['.*', '.'], preg_quote($wildcard_pattern, '/')); return preg_match('/^' . $regex . '$/is', $haystack); }
public function getBlueprintLabels($filter = null) { $labels = []; foreach ($this->config->getBlueprintNames() as $blueprintName) { try { $effectiveStackName = $this->getBlueprint($blueprintName)->getStackName(); } catch (\StackFormation\Exception\InvalidStackNameException $e) { $effectiveStackName = '<fg=red>[Invalid stack name "' . $e->getStackName() . '"]</>'; } catch (\StackFormation\Exception\ValueResolverException $e) { $previousException = $e->getPrevious(); if ($previousException instanceof MissingEnvVarException) { $effectiveStackName = '<fg=red>[Missing env var "' . $previousException->getEnvVar() . '"]</>'; } else { throw $e; } } $label = $blueprintName; if (!is_null($filter) && !Finder::matchWildcard($filter, $label)) { continue; } if ($effectiveStackName != $blueprintName) { $label .= " <fg=yellow>(Effective: {$effectiveStackName})</>"; } $labels[] = $label; } return $labels; }