ZF\Console\Route::getMatchedParam PHP Method

getMatchedParam() public method

Retrieve a matched parameter
public getMatchedParam ( string $param, mixed $default = null ) : mixed
$param string
$default mixed
return mixed
    public function getMatchedParam($param, $default = null)
    {
        if (!$this->matchedParam($param)) {
            return $default;
        }
        return $this->matches[$param];
    }

Usage Example

Example #1
0
 public static function run(Route $route, AdapterInterface $console, $container)
 {
     $error = 0;
     $oldPath = $route->getMatchedParam("old", "/tmp/bench/current.json");
     $newPath = $route->getMatchedParam("new", "./athletic_output.json");
     $old = json_decode(file_get_contents($oldPath), true);
     $new = json_decode(file_get_contents($newPath), true);
     $comparator = $container->get(ComparatorService::class);
     foreach ($new as $group => $values) {
         if (!array_key_exists($group, $old)) {
             continue;
         }
         $newAvg = (double) $values['trigger']['avg'];
         $oldAvg = (double) $old[$group]['trigger']['avg'];
         $perct = $comparator->perctDecrease($newAvg, $oldAvg);
         if ($perct >= 5) {
             $error = 1;
             $console->writeLine("{$group} +{$perct}%", ColorInterface::RED);
         } elseif ($perct < -10) {
             $console->writeLine("{$group} {$perct}%", ColorInterface::GREEN);
         } else {
             $console->writeLine("{$group} {$perct}%", ColorInterface::NORMAL);
         }
     }
     return $error;
 }
All Usage Examples Of ZF\Console\Route::getMatchedParam