<commit_before><?php

namespace Cyclone;

use Carbon\Carbon;

class Generate {
	/**
	 * Generate a product.
	 * @param  [type] $type [description]
	 * @return [type]       [description]
	 */
	public static function product( $type ) {
		// use the factory to create a Faker\Generator instance
		$faker = \Faker\Factory::create();

		// Generate a product name/category etc. from a products csv based on type
		// --- will keep going until it has a unique product title
		do {
			$products = file( plugin_dir_path( __FILE__ ) . '../data/products/' . $type . '.csv' );
			$product = explode( ',' , trim( $products[rand( 0, count( $products ) - 1 )] ) );
			$category = ucfirst( strtolower( $product[0] ) );
			$title = ucwords( strtolower( trim( $product[1] ) ) );
		} while( get_page_by_title( $title, 'OBJECT', 'product' ) );

		// Create product
		$product = [
			'title' => $title,
			'category' => $category,
			'sku' => strtoupper( $faker->numerify( substr( str_replace( ' ', '', $title ), 0, 5 ) . '#####' ) ),
			'content' => implode( "\n\n", $faker->paragraphs( rand( 3, 6 ) ) ),
			'excerpt' => $faker->paragraph( 3 ),
			'price' => $faker->randomFloat( rand( 0, 2 ), 5, 125 ),
		];

		$post_id = wp_insert_post( array(
			'post_type' => 'product',
			'post_title' => $product['title'],
			'post_excerpt' => $product['excerpt'],
			'post_content' => $product['content'],
			'post_status' => 'publish',
		), true );<commit_msg>Make Patrick happy<commit_after><?php

namespace Cyclone;

use Carbon\Carbon;

class Generate {
	/**
	 * Generate a product.
	 * @param  [type] $type [description]
	 * @return [type]       [description]
	 */
	public static function product( $type ) {
		// use the factory to create a Faker\Generator instance
		$faker = \Faker\Factory::create();

		// Generate a product title & category from Faker
		// --- will keep going until it has a unique product title
		do {
			$title = ucwords( $faker->words( 2, true ) );
			$category = $faker->randomElement( array( 'Drama', 'Mystery', 'Romance', 'Horror', 'Travel', 'Health' ) );
		} while( get_page_by_title( $title, 'OBJECT', 'product' ) );

		// Create product
		$product = [
			'title' => $title,
			'category' => $category,
			'sku' => strtoupper( $faker->numerify( substr( str_replace( ' ', '', $title ), 0, 5 ) . '#####' ) ),
			'content' => implode( "\n\n", $faker->paragraphs( rand( 3, 6 ) ) ),
			'excerpt' => $faker->paragraph( 3 ),
			'price' => $faker->randomFloat( rand( 0, 2 ), 5, 125 ),
		];

		$post_id = wp_insert_post( array(
			'post_type' => 'product',
			'post_title' => $product['title'],
			'post_excerpt' => $product['excerpt'],
			'post_content' => $product['content'],
			'post_status' => 'publish',
		), true );
{'fraction_non_alphanumeric': 0.19683590875643855, 'fraction_numerical': 0.009933774834437087, 'mean_word_length': 3.44281045751634, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '5239107', 'n_tokens_mistral': 1059, 'n_tokens_neox': 925, 'n_words': 247}