<commit_before><?php

namespace Zeroplusone\Patchr\Helpers;

/**
 * Class Filesystem
 * @package Zeroplusone\Patchr\Helpers
 * @copyright 2014-2017 <NAME>
 */
class Filesystem
{

  /**
   * Create the next available patch
   *
   * @param type $latestPatchName
   * @param type $sql
   * @return string
   */
  public static function createNextAvailablePatch($patchr_config, $latestPatchName, $sql = NULL)
  {
      //Generates the next free patch name
      $generateNextPatchName = function($number, $naming)
      {
          $name = '';
          $name .= $naming['prefix'];
          $name .= str_pad( ($number+1) , $naming['digits'], "0", STR_PAD_LEFT);
          $name .= $naming['extension'];
          return $name;
      };
      //We are requesting the first possible patch
      if( is_null($latestPatchName) )
      {
          $generatedPatchName = $generateNextPatchName(0,$patchr_config['naming']);
      }
      else
      {
          //Extract the raw patch number from the patch name
          $patchnumber_withextension = str_replace($patchr_config['naming']['prefix'],'',$latestPatchName);
          $patchnumber_padded = str_replace($patchr_config['naming']['extension'],'',$patchnumber_withextension);
          $patchnumber = ltrim($patchnumber_padded, '0');
          //Request the next available patchname
          $generatedPatchName = $generateNextPatchName($patchnumber,$patchr_config['naming']);
      }
      //Write file to disk die('dasdacc');
      return self::createFileOnDisk($patchr_config['naming']['patches_dir'], $generatedPatchName, $sql);
  }

    /**
     * Create File
     *
     * @param type $directory
     * @param type $filename<commit_msg>Force int typecast to guarantee compatibility with php 7.1<commit_after><?php

namespace Zeroplusone\Patchr\Helpers;

/**
 * Class Filesystem
 * @package Zeroplusone\Patchr\Helpers
 * @copyright 2014-2017 <NAME>
 */
class Filesystem
{

  /**
   * Create the next available patch
   *
   * @param type $latestPatchName
   * @param type $sql
   * @return string
   */
  public static function createNextAvailablePatch($patchr_config, $latestPatchName, $sql = NULL)
  {
      //Generates the next free patch name
      $generateNextPatchName = function($number, $naming)
      {
          $name = '';
          $name .= $naming['prefix'];
          $name .= str_pad( ((int)$number+1) , (int)$naming['digits'], "0", STR_PAD_LEFT);
          $name .= $naming['extension'];
          return $name;
      };
      //We are requesting the first possible patch
      if( is_null($latestPatchName) )
      {
          $generatedPatchName = $generateNextPatchName(0,$patchr_config['naming']);
      }
      else
      {
          //Extract the raw patch number from the patch name
          $patchnumber_withextension = str_replace($patchr_config['naming']['prefix'],'',$latestPatchName);
          $patchnumber_padded = str_replace($patchr_config['naming']['extension'],'',$patchnumber_withextension);
          $patchnumber = ltrim($patchnumber_padded, '0');
          //Request the next available patchname
          $generatedPatchName = $generateNextPatchName($patchnumber,$patchr_config['naming']);
      }
      //Write file to disk die('dasdacc');
      return self::createFileOnDisk($patchr_config['naming']['patches_dir'], $generatedPatchName, $sql);
  }

    /**
     * Create File
     *
     * @param type $directory
     * @param type $filename
{'fraction_non_alphanumeric': 0.13463216051177668, 'fraction_numerical': 0.00756033730735679, 'mean_word_length': 3.0093240093240095, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '90835', 'n_tokens_mistral': 1026, 'n_tokens_neox': 1019, 'n_words': 219}