PDepend\Input\ExtensionFilter::accept PHP Method

accept() public method

Returns true if this filter accepts the given paths.
public accept ( string $relative, string $absolute ) : boolean
$relative string The relative path to the specified root.
$absolute string The absolute path to a source file.
return boolean
    public function accept($relative, $absolute)
    {
        if (strpos($absolute, 'php://') === 0) {
            return true;
        }
        $extension = pathinfo($relative, PATHINFO_EXTENSION);
        return in_array($extension, $this->extensions);
    }

Usage Example

 /**
  * Creates an array with those files that were acceptable for the extension
  * filter.
  *
  * @param array(string) $includes The file extensions
  *
  * @return array(string)
  */
 protected function createFilteredFileList(array $includes)
 {
     $filter = new ExtensionFilter($includes);
     $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(self::createCodeResourceUriForTest()));
     $actual = array();
     foreach ($files as $file) {
         if ($filter->accept($file, $file) && $file->isFile() && false === stripos($file->getPathname(), '.svn')) {
             $actual[] = $file->getFilename();
         }
     }
     sort($actual);
     return $actual;
 }
ExtensionFilter