filterByPrefix() public method

Returns a new index object which contains all class names of this index starting with the given prefix
public filterByPrefix ( string $prefixFilter ) : ClassNameIndex
$prefixFilter string A prefix string to filter the class names of this index
return ClassNameIndex A new index object
 /**
  * @test
  */
 public function filterByPrefixWork()
 {
     $index1 = new Aop\Builder\ClassNameIndex();
     $index1->setClassNames(['\\Foo\\Bar', '\\Foo\\Baz', '\\Bar\\Baz', '\\Foo\\Blubb']);
     // We need to call sort manually!
     $index1->sort();
     $filteredIndex = $index1->filterByPrefix('\\Foo');
     $this->assertEquals(['\\Foo\\Bar', '\\Foo\\Baz', '\\Foo\\Blubb'], $filteredIndex->getClassNames());
 }
 /**
  * This method is used to optimize the matching process.
  *
  * @param ClassNameIndex $classNameIndex
  * @return ClassNameIndex
  */
 public function reduceTargetClassNames(ClassNameIndex $classNameIndex)
 {
     if (!preg_match('/^([^\\.\\(\\)\\{\\}\\[\\]\\?\\+\\$\\!\\|]+)/', $this->originalExpressionString, $matches)) {
         return $classNameIndex;
     }
     $prefixFilter = $matches[1];
     // We sort here to make sure the index is okay
     $classNameIndex->sort();
     return $classNameIndex->filterByPrefix($prefixFilter);
 }