original_string: public static function MakeOfType(array $esHit, $className = "", Client $esClient = null) {
          if ($className && strpos($className, '{type}') !== false) {
              $baseClassName = str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9]+/', ' ', $esHit['_type'])));
              $fullClassName = str_replace("{type}", $baseClassName, $className);
              if (!class_exists($fullClassName)) {
                  $fullClassName = array_key_exists('_source', $esHit) ? static::class : ArrayObject::class;
              }
          } else {
              $fullClassName = $className? : static::class;
          }
          return $fullClassName::make($esHit, $esClient);
      }
code: public static function MakeOfType(array $esHit, $className = "", Client $esClient = null) {
          if ($className && strpos($className, '{type}') !== false) {
              $baseClassName = str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9]+/', ' ', $esHit['_type'])));
              $fullClassName = str_replace("{type}", $baseClassName, $className);
              if (!class_exists($fullClassName)) {
                  $fullClassName = array_key_exists('_source', $esHit) ? static::class : ArrayObject::class;
              }
          } else {
              $fullClassName = $className? : static::class;
          }
          return $fullClassName::make($esHit, $esClient);
      }
code_tokens: public static function MakeOfType ( array $ esHit , $ className = "" , Client $ esClient = null ) { if ( $ className && strpos ( $ className , '{type}' ) !== false ) { $ baseClassName = str_replace ( ' ' , '' , ucwords ( preg_replace ( '/[^a-zA-Z0-9]+/' , ' ' , $ esHit [ '_type' ] ) ) ) ; $ fullClassName = str_replace ( "{type}" , $ baseClassName , $ className ) ; if ( ! class_exists ( $ fullClassName ) ) { $ fullClassName = array_key_exists ( '_source' , $ esHit ) ? static :: class : ArrayObject :: class ; } } else { $ fullClassName = $ className ? : static :: class ; } return $ fullClassName :: make ( $ esHit , $ esClient ) ; }
docstring: A custom factory method that will try to detect the correct model class
  and instantiate and object of it.
  
  @param array $esHit
  @param string $className a class name or pattern.
  @param Client $esClient ElasticSearch client
  @return Model
docstring_tokens: A custom factory method that will try to detect the correct model class and instantiate and object of it .