original_string: public static function get_matching_tourdata(\moodle_url $targetmatch) {
          $tours = self::get_enabled_tourdata();
  
          // Attempt to determine whether this is the front page.
          // This is a special case because the frontpage uses a shortened page path making it difficult to detect exactly.
          $isfrontpage = $targetmatch->compare(new \moodle_url('/'), URL_MATCH_BASE);
          $target = $targetmatch->out_as_local_url();
          return array_filter($tours, function($tour) use ($isfrontpage, $target) {
              if ($isfrontpage && $tour->pathmatch === 'FRONTPAGE') {
                  return true;
              }
              $pattern = preg_quote($tour->pathmatch, '@');
              $pattern = str_replace('%', '.*', $pattern);
              return !!preg_match("@{$pattern}@", $target);
          });
      }
code: public static function get_matching_tourdata(\moodle_url $targetmatch) {
          $tours = self::get_enabled_tourdata();
  
          // Attempt to determine whether this is the front page.
          // This is a special case because the frontpage uses a shortened page path making it difficult to detect exactly.
          $isfrontpage = $targetmatch->compare(new \moodle_url('/'), URL_MATCH_BASE);
          $target = $targetmatch->out_as_local_url();
          return array_filter($tours, function($tour) use ($isfrontpage, $target) {
              if ($isfrontpage && $tour->pathmatch === 'FRONTPAGE') {
                  return true;
              }
              $pattern = preg_quote($tour->pathmatch, '@');
              $pattern = str_replace('%', '.*', $pattern);
              return !!preg_match("@{$pattern}@", $target);
          });
      }
code_tokens: public static function get_matching_tourdata ( \ moodle_url $ targetmatch ) { $ tours = self :: get_enabled_tourdata ( ) ; // Attempt to determine whether this is the front page. // This is a special case because the frontpage uses a shortened page path making it difficult to detect exactly. $ isfrontpage = $ targetmatch -> compare ( new \ moodle_url ( '/' ) , URL_MATCH_BASE ) ; $ target = $ targetmatch -> out_as_local_url ( ) ; return array_filter ( $ tours , function ( $ tour ) use ( $ isfrontpage , $ target ) { if ( $ isfrontpage && $ tour -> pathmatch === 'FRONTPAGE' ) { return true ; } $ pattern = preg_quote ( $ tour -> pathmatch , '@' ) ; $ pattern = str_replace ( '%' , '.*' , $ pattern ) ; return ! ! preg_match ( "@{$pattern}@" , $ target ) ; } ) ; }
docstring: Fetch all enabled tours matching the specified target.
  
  @param   moodle_url  $targetmatch    The URL to match.
docstring_tokens: Fetch all enabled tours matching the specified target .