예제 #1
0
 /**
  * Check whether the Findable can handle an individual criterion.
  *
  * @since 0.1.0
  *
  * @param mixed $criterion Criterion to check.
  *
  * @return bool Whether the Findable can handle the criterion.
  */
 public function canHandle($criterion)
 {
     return URIHelper::hasExtension($criterion, static::PHP_EXTENSION) && is_readable($criterion);
 }
예제 #2
0
 /**
  * Get the name pattern to pass to the file finder.
  *
  * @since 0.1.3
  *
  * @param array  $criteria  Criteria to match.
  * @param string $extension Extension to match.
  *
  * @return string Name pattern to pass to the file finder.
  */
 protected function getNamePattern(array $criteria, $extension)
 {
     $names = [];
     $names[] = array_map(function ($criterion) use($extension) {
         $criterion = URIHelper::getFilename($criterion);
         return empty($extension) || URIHelper::hasExtension($criterion, $extension) ? $criterion : $criterion . $extension;
     }, $criteria)[0];
     return $this->arrayToRegexPattern(array_unique($names));
 }