original_string: protected function getFilePathFromKey($key)
      {
          $key = basename($key);
          $badChars = ['-', '.', '_', '\\', '*', '\"', '?', '[', ']', ':', ';', '|', '=', ','];
          $key = str_replace($badChars, '/', $key);
          while (strpos($key, '//') !== false) {
              $key = str_replace('//', '/', $key);
          }
  
          $directoryToCreate = $this->config['cacheDirectory'];
  
          $endOfDirectory = strrpos($key, '/');
  
          if ($endOfDirectory !== false) {
              $directoryToCreate = $this->config['cacheDirectory'].substr($key, 0, $endOfDirectory);
          }
  
          if (!file_exists($directoryToCreate)) {
              $result = mkdir($directoryToCreate, 0777, true);
              if (!$result) {
                  return false;
              }
          }
  
          $filePath = $this->config['cacheDirectory'].$key.'.'.$this->config['fileExtension'];
  
          return $filePath;
      }
code: protected function getFilePathFromKey($key)
      {
          $key = basename($key);
          $badChars = ['-', '.', '_', '\\', '*', '\"', '?', '[', ']', ':', ';', '|', '=', ','];
          $key = str_replace($badChars, '/', $key);
          while (strpos($key, '//') !== false) {
              $key = str_replace('//', '/', $key);
          }
  
          $directoryToCreate = $this->config['cacheDirectory'];
  
          $endOfDirectory = strrpos($key, '/');
  
          if ($endOfDirectory !== false) {
              $directoryToCreate = $this->config['cacheDirectory'].substr($key, 0, $endOfDirectory);
          }
  
          if (!file_exists($directoryToCreate)) {
              $result = mkdir($directoryToCreate, 0777, true);
              if (!$result) {
                  return false;
              }
          }
  
          $filePath = $this->config['cacheDirectory'].$key.'.'.$this->config['fileExtension'];
  
          return $filePath;
      }
code_tokens: protected function getFilePathFromKey ( $ key ) { $ key = basename ( $ key ) ; $ badChars = [ '-' , '.' , '_' , '\\' , '*' , '\"' , '?' , '[' , ']' , ':' , ';' , '|' , '=' , ',' ] ; $ key = str_replace ( $ badChars , '/' , $ key ) ; while ( strpos ( $ key , '//' ) !== false ) { $ key = str_replace ( '//' , '/' , $ key ) ; } $ directoryToCreate = $ this -> config [ 'cacheDirectory' ] ; $ endOfDirectory = strrpos ( $ key , '/' ) ; if ( $ endOfDirectory !== false ) { $ directoryToCreate = $ this -> config [ 'cacheDirectory' ] . substr ( $ key , 0 , $ endOfDirectory ) ; } if ( ! file_exists ( $ directoryToCreate ) ) { $ result = mkdir ( $ directoryToCreate , 0777 , true ) ; if ( ! $ result ) { return false ; } } $ filePath = $ this -> config [ 'cacheDirectory' ] . $ key . '.' . $ this -> config [ 'fileExtension' ] ; return $ filePath ; }
docstring: Returns the file path from a given cache key, creating the relevant directory structure if necessary.
  
  @param string $key
  
  @return string
docstring_tokens: Returns the file path from a given cache key creating the relevant directory structure if necessary .