<commit_before><?php

class Str {
	/**
	 * This class will contain
	 * string methods
	 */

	/**
	 * @param $string
	 * @param $char
	 * @return boolean
	 *
	 * Returns true if the last character
	 * of the given string is the same as the
	 * given character
	 */
	public static function last_char($string, $char) {
		$string = str_split($string);
		$last_char = $string[count($string) -1];
		
		if ($last_char == $char) 
			return true;
		 else 
			return false;
	}

	/**
	 * @param $string
	 * @param $char
	 * @return boolean
	 *
	 * Returns true if the first character
	 * of the given string is the same as the
	 * given character
	 */
	public static function first_char($string, $char) {
		$string = str_split($string);
		$first_char = $string[0];

		if ($first_char == $char) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * @param $haystack
	 * @param $needle
	 * @return boolean
	 *
	 * Returns true if the given string
	 * contains the given substring
	 */
	public static function contains($haystack, $needle) {
		if (strstr($haystack, $needle)) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * @param $string<commit_msg>Upgraded the Str::contains method to accept arrays<commit_after><?php

class Str {
	/**
	 * This class will contain
	 * string methods
	 */

	/**
	 * @param $string
	 * @param $char
	 * @return boolean
	 *
	 * Returns true if the last character
	 * of the given string is the same as the
	 * given character
	 */
	public static function last_char($string, $char) {
		$string = str_split($string);
		$last_char = $string[count($string) -1];
		
		if ($last_char == $char) 
			return true;
		 else 
			return false;
	}

	/**
	 * @param $string
	 * @param $char
	 * @return boolean
	 *
	 * Returns true if the first character
	 * of the given string is the same as the
	 * given character
	 */
	public static function first_char($string, $char) {
		$string = str_split($string);
		$first_char = $string[0];

		if ($first_char == $char) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * @param $haystack
	 * @param $needle
	 * @param $checkall
	 * @return boolean
	 *
	 * Returns true if the given string
	 * contains the given substring
	 */
	public static function contains($haystack, $needle, $checkall = false) {
		/*
		 * @var string
		 */
		$contains = false;

		if (is_string($needle)) {
			if (strstr($haystack, $needle)) {
				$contains =  true;
			} else {
				return $contains;
			}
		} else if (is_array($needle) && !$checkall) {
			foreach ($needle as $check) {
				if (strstr($haystack, $check)) {
					$contains = true;
				}
			}
		} else if (is_array($needle) && $checkall) {
			$checked_needles = [];

			foreach ($needle as $check) {
				if (strstr($haystack, $check)) {
					$checked_needles[] = $check;
				}
			}

			if (Arr::size($checked_needles) == Arr::size($needle)) {
				$contains = true;
			}
		}

		return $contains;
	}

	/**
	 * @param $string
{'fraction_non_alphanumeric': 0.14106050305914344, 'fraction_numerical': 0.0013596193065941536, 'mean_word_length': 2.8171206225680936, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '7080863', 'n_tokens_mistral': 1144, 'n_tokens_neox': 960, 'n_words': 291}