original_string: public function getPackageBundle()
      {
          // specific name
          if (($class = $this->getPackageOption('anime-db-bundle')) && class_exists($class)) {
              return $class;
          }
  
          // package with the bundle can contain the word a 'bundle' in the name
          $name = preg_replace('/(\/.+)[^a-z]bundle$/i', '$1', $this->package->getName());
          // convert package name to bundle name
          $name = preg_replace('/[^a-zA-Z\/]+/', ' ', $name);
          $name = ucwords(str_replace('/', ' / ', $name));
          list($vendor, $bundle) = explode('/', str_replace(' ', '', $name), 2);
  
          $classes = [
              '\\'.$vendor.'\Bundle\\'.$bundle.'Bundle\\'.$vendor.$bundle.'Bundle',
              '\\'.$vendor.'\Bundle\\'.$bundle.'Bundle\\'.$bundle.'Bundle',
          ];
  
          // vendor name can be contained in the bundle name
          // knplabs/knp-menu-bundle -> \Knp\Bundle\MenuBundle\KnpMenuBundle
          list(, $bundle) = explode('/', $name, 2);
          $bundle = trim($bundle);
          if (($pos = strpos($bundle, ' ')) !== false) {
              $vendor = substr($bundle, 0, $pos);
              $bundle = str_replace(' ', '', substr($bundle, $pos + 1));
              $classes[] = '\\'.$vendor.'\Bundle\\'.$bundle.'Bundle\\'.$vendor.$bundle.'Bundle';
              $classes[] = '\\'.$vendor.'\Bundle\\'.$bundle.'Bundle\\'.$bundle.'Bundle';
          }
  
          foreach ($classes as $class) {
              if (class_exists($class)) {
                  // cache the bundle class
                  $options = $this->package->getExtra();
                  $options['anime-db-bundle'] = $class;
                  $this->package->setExtra($options);
  
                  return $class;
              }
          }
  
          return;
      }
code: public function getPackageBundle()
      {
          // specific name
          if (($class = $this->getPackageOption('anime-db-bundle')) && class_exists($class)) {
              return $class;
          }
  
          // package with the bundle can contain the word a 'bundle' in the name
          $name = preg_replace('/(\/.+)[^a-z]bundle$/i', '$1', $this->package->getName());
          // convert package name to bundle name
          $name = preg_replace('/[^a-zA-Z\/]+/', ' ', $name);
          $name = ucwords(str_replace('/', ' / ', $name));
          list($vendor, $bundle) = explode('/', str_replace(' ', '', $name), 2);
  
          $classes = [
              '\\'.$vendor.'\Bundle\\'.$bundle.'Bundle\\'.$vendor.$bundle.'Bundle',
              '\\'.$vendor.'\Bundle\\'.$bundle.'Bundle\\'.$bundle.'Bundle',
          ];
  
          // vendor name can be contained in the bundle name
          // knplabs/knp-menu-bundle -> \Knp\Bundle\MenuBundle\KnpMenuBundle
          list(, $bundle) = explode('/', $name, 2);
          $bundle = trim($bundle);
          if (($pos = strpos($bundle, ' ')) !== false) {
              $vendor = substr($bundle, 0, $pos);
              $bundle = str_replace(' ', '', substr($bundle, $pos + 1));
              $classes[] = '\\'.$vendor.'\Bundle\\'.$bundle.'Bundle\\'.$vendor.$bundle.'Bundle';
              $classes[] = '\\'.$vendor.'\Bundle\\'.$bundle.'Bundle\\'.$bundle.'Bundle';
          }
  
          foreach ($classes as $class) {
              if (class_exists($class)) {
                  // cache the bundle class
                  $options = $this->package->getExtra();
                  $options['anime-db-bundle'] = $class;
                  $this->package->setExtra($options);
  
                  return $class;
              }
          }
  
          return;
      }
code_tokens: public function getPackageBundle ( ) { // specific name if ( ( $ class = $ this -> getPackageOption ( 'anime-db-bundle' ) ) && class_exists ( $ class ) ) { return $ class ; } // package with the bundle can contain the word a 'bundle' in the name $ name = preg_replace ( '/(\/.+)[^a-z]bundle$/i' , '$1' , $ this -> package -> getName ( ) ) ; // convert package name to bundle name $ name = preg_replace ( '/[^a-zA-Z\/]+/' , ' ' , $ name ) ; $ name = ucwords ( str_replace ( '/' , ' / ' , $ name ) ) ; list ( $ vendor , $ bundle ) = explode ( '/' , str_replace ( ' ' , '' , $ name ) , 2 ) ; $ classes = [ '\\' . $ vendor . '\Bundle\\' . $ bundle . 'Bundle\\' . $ vendor . $ bundle . 'Bundle' , '\\' . $ vendor . '\Bundle\\' . $ bundle . 'Bundle\\' . $ bundle . 'Bundle' , ] ; // vendor name can be contained in the bundle name // knplabs/knp-menu-bundle -> \Knp\Bundle\MenuBundle\KnpMenuBundle list ( , $ bundle ) = explode ( '/' , $ name , 2 ) ; $ bundle = trim ( $ bundle ) ; if ( ( $ pos = strpos ( $ bundle , ' ' ) ) !== false ) { $ vendor = substr ( $ bundle , 0 , $ pos ) ; $ bundle = str_replace ( ' ' , '' , substr ( $ bundle , $ pos + 1 ) ) ; $ classes [ ] = '\\' . $ vendor . '\Bundle\\' . $ bundle . 'Bundle\\' . $ vendor . $ bundle . 'Bundle' ; $ classes [ ] = '\\' . $ vendor . '\Bundle\\' . $ bundle . 'Bundle\\' . $ bundle . 'Bundle' ; } foreach ( $ classes as $ class ) { if ( class_exists ( $ class ) ) { // cache the bundle class $ options = $ this -> package -> getExtra ( ) ; $ options [ 'anime-db-bundle' ] = $ class ; $ this -> package -> setExtra ( $ options ) ; return $ class ; } } return ; }
docstring: Get the bundle from package.
  
  For example package name 'demo-vendor/foo-bar-bundle' converted to:
  \DemoVendor\Bundle\FooBarBundle\DemoVendorFooBarBundle
  \DemoVendor\Bundle\FooBarBundle\FooBarBundle
  \Foo\Bundle\BarBundle\FooBarBundle
  \Foo\Bundle\BarBundle\BarBundle
  
  @return string|null
docstring_tokens: Get the bundle from package .