/**
  * Test sorting
  *
  * @test
  */
 public function testSorting()
 {
     $registry = new BaseClassRegistry();
     $registry->register(DummyClass::class, 'MyTest_*', 10);
     $registry->register(SecondDummyClass::class, 'MyTest_Foo_*', 20);
     $registry->register(DummyClass::class, 'MyTest_*_Bar', 30);
     $this->assertEquals(DummyClass::class, $registry->find('MyTest_A'));
     $this->assertEquals(SecondDummyClass::class, $registry->find('MyTest_Foo_B'));
     $this->assertEquals(DummyClass::class, $registry->find('MyTest_Foo_B_Bar'));
     $this->assertEquals(BaseMock::class, $registry->find('Foobar'));
     $this->assertEquals(BaseMock::class, $registry->find(''));
 }
 /**
  * Generate class using any given references or traits
  *
  * @param string $className
  *
  * @return FileGenerator
  */
 public function build($className)
 {
     $footprint = $this->_footprintRegistry->get($className);
     $parentClass = $footprint->getParent();
     if (!$parentClass) {
         $parentClass = $this->_baseClassRegistry->find($className);
     }
     if ($footprint->isInterface()) {
         $generator = new InterfaceGenerator();
     } else {
         $traits = $this->_traitRegistry->findByClass($className);
         $generator = new ClassGenerator();
         $generator->useTraits($traits);
     }
     $generator->setName($className);
     $generator->setExtendedClass($parentClass);
     $generator->setImplementedInterfaces($footprint->getInterfaces());
     foreach ($footprint->getConstants() as $name => $value) {
         $generator->addConstant($name, $value);
     }
     $file = new FileGenerator();
     $file->setClass($generator);
     return $file;
 }