<commit_before><?php

namespace common\modules\lead\models;

use common\helpers\ArrayHelper;
use common\modules\lead\models\forms\LeadForm;
use DateTime;
use Exception;
use ruskid\csvimporter\CSVImporter;
use ruskid\csvimporter\CSVReader;
use ruskid\csvimporter\ImportInterface;
use ruskid\csvimporter\MultipleImportStrategy;
use Yii;
use yii\base\InvalidArgumentException;
use yii\base\Model;
use yii\behaviors\AttributeTypecastBehavior;
use yii\helpers\Json;
use yii\web\UploadedFile;

class LeadCSVImport extends Model {

	public const DELIMITER_COMMA = ',';
	public const DELIMITER_SEMICOLON = ';';
	public const DELIMITER_COLON = ':';

	/**
	 * @var UploadedFile
	 */
	public $csvFile;

	public int $phoneColumn = 0;
	public $nameColumn = 1;
	public $dateColumn = 2;

	public string $csvDelimiter = self::DELIMITER_SEMICOLON;
	public int $startFromLine = 1;

	public int $status_id = LeadStatus::STATUS_NEW;
	public $source_id;
	public ?string $provider = null;

	private int $index = 0;
	public string $dateFormat = 'Y-m-d H:i';

	public function behaviors(): array {
		return [
			'typecast' => [
				'class' => AttributeTypecastBehavior::class,
			],
		];
	}

	public static function getProvidersNames(): array {
		return Lead::getProvidersNames();
	}

	public function rules(): array {
		return [
			[['source_id', 'status_id', 'phoneColumn', 'csvDelimiter', 'startFromLine'], 'required'],
			[['phoneColumn', 'nameColumn', 'dateColumn', 'startFromLine'], 'integer', 'min' => 0],
			[['nameColumn', 'dateColumn'], 'default', 'value' => 'null'],
			[['source_id', 'status_id'], 'integer'],
			[
				'!csvFile',
				'file',
				'extensions' => 'csv',
				'skipOnEmpty' => false,
				'checkExtensionByMimeType' => false,
			],
			['source_id', 'in', 'range' => array_keys(static::getSourcesNames())],<commit_msg>fix:  nameColumn default rule.<commit_after><?php

namespace common\modules\lead\models;

use common\helpers\ArrayHelper;
use common\modules\lead\models\forms\LeadForm;
use DateTime;
use Exception;
use ruskid\csvimporter\CSVImporter;
use ruskid\csvimporter\CSVReader;
use ruskid\csvimporter\ImportInterface;
use ruskid\csvimporter\MultipleImportStrategy;
use Yii;
use yii\base\InvalidArgumentException;
use yii\base\Model;
use yii\behaviors\AttributeTypecastBehavior;
use yii\helpers\Json;
use yii\web\UploadedFile;

class LeadCSVImport extends Model {

	public const DELIMITER_COMMA = ',';
	public const DELIMITER_SEMICOLON = ';';
	public const DELIMITER_COLON = ':';

	/**
	 * @var UploadedFile
	 */
	public $csvFile;

	public int $phoneColumn = 0;
	public $nameColumn = 1;
	public $dateColumn = 2;

	public string $csvDelimiter = self::DELIMITER_SEMICOLON;
	public int $startFromLine = 1;

	public int $status_id = LeadStatus::STATUS_NEW;
	public $source_id;
	public ?string $provider = null;

	private int $index = 0;
	public string $dateFormat = 'Y-m-d H:i';

	public function behaviors(): array {
		return [
			'typecast' => [
				'class' => AttributeTypecastBehavior::class,
			],
		];
	}

	public static function getProvidersNames(): array {
		return Lead::getProvidersNames();
	}

	public function rules(): array {
		return [
			[['source_id', 'status_id', 'phoneColumn', 'csvDelimiter', 'startFromLine'], 'required'],
			[['phoneColumn', 'nameColumn', 'dateColumn', 'startFromLine'], 'integer', 'min' => 0],
			[['nameColumn', 'dateColumn'], 'default', 'value' => null],
			[['source_id', 'status_id'], 'integer'],
			[
				'!csvFile',
				'file',
				'extensions' => 'csv',
				'skipOnEmpty' => false,
				'checkExtensionByMimeType' => false,
			],
			['source_id', 'in', 'range' => array_keys(static::getSourcesNames())],
{'fraction_non_alphanumeric': 0.1500958641468091, 'fraction_numerical': 0.003286770747740345, 'mean_word_length': 4.967320261437909, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '1877221', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1241, 'n_words': 278}