function article_search($search_str, array $arr, array $paths, $current_path = '') { if (is_string($search_str) && strlen($search_str) > 0) { $depth = substr_count($current_path, "."); $loop_cntr = 0; foreach ($arr as $key => $value) { if ($loop_cntr > 0) { // replace last path key value $path_arr = explode('.', $current_path); $path_size = count($path_arr); if ($path_size > 0) { $path_arr[$path_size - 1] = $key; } $current_path = implode('.', $path_arr); } else { if (strlen($current_path) > 0) { $current_path .= "."; } $current_path .= $key; } if (is_object($value) || is_array($value)) { $paths = article_search($search_str, $value, $paths, $current_path); } else { if (is_string($value) && hasString($value, $search_str)) { array_push($paths, $current_path); } } $loop_cntr++; } } return $paths; }
/** * An expectation for checking substring of a page url. * * @param string $urlPart The expected substring of url. * @return CustomExpectedCondition<bool> True when in url, * false otherwise. */ public static function currentUrlContains($urlPart) { return new CustomExpectedCondition(function ($driver) use($urlPart) { return hasString($driver->getCurrentURL(), $urlPart); }); }