original_string: public function getConsts($prefix)
      {
          if (isset(self::$consts[$prefix])) {
              return self::$consts[$prefix];
          }
  
          // 1. Get all class constants
          $class = new \ReflectionClass($this);
          $consts = $class->getConstants();
  
          // 2. Use exiting constant configs
          $property = lcfirst(str_replace('_', '', ucwords($prefix, '_'))) . 'Table';
          if (isset($this->$property)) {
              $data = $this->$property;
          } else {
              $data = [];
          }
  
          // 3. Generate id and name
          $prefix .= '_';
          $length = strlen($prefix);
          foreach ($consts as $name => $id) {
              if (stripos($name, $prefix) !== 0) {
                  continue;
              }
              if (in_array($name, $this->constExcludes)) {
                  continue;
              }
              $data[$id]['id'] = $id;
              $data[$id]['name'] = strtolower(strtr(substr($name, $length), ['_' => '-']));
          }
  
          self::$consts[$prefix] = $data;
  
          return $data;
      }
code: public function getConsts($prefix)
      {
          if (isset(self::$consts[$prefix])) {
              return self::$consts[$prefix];
          }
  
          // 1. Get all class constants
          $class = new \ReflectionClass($this);
          $consts = $class->getConstants();
  
          // 2. Use exiting constant configs
          $property = lcfirst(str_replace('_', '', ucwords($prefix, '_'))) . 'Table';
          if (isset($this->$property)) {
              $data = $this->$property;
          } else {
              $data = [];
          }
  
          // 3. Generate id and name
          $prefix .= '_';
          $length = strlen($prefix);
          foreach ($consts as $name => $id) {
              if (stripos($name, $prefix) !== 0) {
                  continue;
              }
              if (in_array($name, $this->constExcludes)) {
                  continue;
              }
              $data[$id]['id'] = $id;
              $data[$id]['name'] = strtolower(strtr(substr($name, $length), ['_' => '-']));
          }
  
          self::$consts[$prefix] = $data;
  
          return $data;
      }
code_tokens: public function getConsts ( $ prefix ) { if ( isset ( self :: $ consts [ $ prefix ] ) ) { return self :: $ consts [ $ prefix ] ; } // 1. Get all class constants $ class = new \ ReflectionClass ( $ this ) ; $ consts = $ class -> getConstants ( ) ; // 2. Use exiting constant configs $ property = lcfirst ( str_replace ( '_' , '' , ucwords ( $ prefix , '_' ) ) ) . 'Table' ; if ( isset ( $ this -> $ property ) ) { $ data = $ this -> $ property ; } else { $ data = [ ] ; } // 3. Generate id and name $ prefix .= '_' ; $ length = strlen ( $ prefix ) ; foreach ( $ consts as $ name => $ id ) { if ( stripos ( $ name , $ prefix ) !== 0 ) { continue ; } if ( in_array ( $ name , $ this -> constExcludes ) ) { continue ; } $ data [ $ id ] [ 'id' ] = $ id ; $ data [ $ id ] [ 'name' ] = strtolower ( strtr ( substr ( $ name , $ length ) , [ '_' => '-' ] ) ) ; } self :: $ consts [ $ prefix ] = $ data ; return $ data ; }
docstring: Get constants table by prefix
  
  @param string $prefix
  @return array
docstring_tokens: Get constants table by prefix