public function testFindOrDefault() { $array = ["one" => "hat", "two" => "cat", "three" => "sat"]; $default = (string) rand(); // ArrayUtils finds the correct value when the key is present. $this->assertEquals($array["one"], ArrayUtils::findOrDefault("one", $array, $default)); // ArrayUtils provides the default when the key is not present. $this->assertEquals($default, ArrayUtils::findOrDefault("four", $array, $default)); }
/** * @param string $key * @param string $default * @return string */ protected function getParameter($key, $default = null) { return ArrayUtils::findOrDefault($key, $_GET, $default); }