<commit_before><?php

/**
 * User property that handle relationship between
 * users and posts.
 */
class Papi_Property_User extends Papi_Property_Dropdown {

	/**
	 * The convert type.
	 *
	 * @var string
	 */
	public $convert_type = 'int';

	/**
	 * Format the value of the property before it's returned
	 * to WordPress admin or the site.
	 *
	 * @param  mixed  $value
	 * @param  string $slug
	 * @param  int    $post_id
	 *
	 * @return array
	 */
	public function format_value( $value, $slug, $post_id ) {
		if ( is_object( $value ) && isset( $value->ID ) ) {
			$value = $value->ID;
		}

		if ( is_numeric( $value ) ) {
			return new WP_User( $value );
		}

		return $value;
	}

	/**
	 * Get default settings.
	 *
	 * @return array
	 */
	public function get_default_settings() {
		return [
			'capabilities' => [],
			'placeholder'  => '',
			'select2'      => true
		];
	}

	/**
	 * Get value from database.
	 *
	 * @return int
	 */
	public function get_value() {
		$user = parent::get_value();

		if ( is_object( $user ) && isset( $user->ID ) ) {
			return $user->ID;
		}

		return 0;
	}

	/**
	 * Get users as dropdown items.
	 *
	 * @return array
	 */
	public function get_items() {
		$capabilities = papi_to_array( $this->get_setting( 'capabilities' ) );
		$users        = get_users();
		$items        = [];

		foreach ( $users as $user ) {
			$allcaps = $user->allcaps;

			if ( count( array_diff( $capabilities, array_keys( $allcaps ) ) ) === 0 ) {
				$items[$user->display_name] = $user->ID;
			}
		}

		ksort( $items );
		return $items;
	}

	/**
	 * Import value to the property.
	 *
	 * @param  mixed  $value
	 * @param  string $slug
	 * @param  int    $post_id
	 *<commit_msg>Add new line between return and ksort<commit_after><?php

/**
 * User property that handle relationship between
 * users and posts.
 */
class Papi_Property_User extends Papi_Property_Dropdown {

	/**
	 * The convert type.
	 *
	 * @var string
	 */
	public $convert_type = 'int';

	/**
	 * Format the value of the property before it's returned
	 * to WordPress admin or the site.
	 *
	 * @param  mixed  $value
	 * @param  string $slug
	 * @param  int    $post_id
	 *
	 * @return array
	 */
	public function format_value( $value, $slug, $post_id ) {
		if ( is_object( $value ) && isset( $value->ID ) ) {
			$value = $value->ID;
		}

		if ( is_numeric( $value ) ) {
			return new WP_User( $value );
		}

		return $value;
	}

	/**
	 * Get default settings.
	 *
	 * @return array
	 */
	public function get_default_settings() {
		return [
			'capabilities' => [],
			'placeholder'  => '',
			'select2'      => true
		];
	}

	/**
	 * Get value from database.
	 *
	 * @return int
	 */
	public function get_value() {
		$user = parent::get_value();

		if ( is_object( $user ) && isset( $user->ID ) ) {
			return $user->ID;
		}

		return 0;
	}

	/**
	 * Get users as dropdown items.
	 *
	 * @return array
	 */
	public function get_items() {
		$capabilities = papi_to_array( $this->get_setting( 'capabilities' ) );
		$users        = get_users();
		$items        = [];

		foreach ( $users as $user ) {
			$allcaps = $user->allcaps;

			if ( count( array_diff( $capabilities, array_keys( $allcaps ) ) ) === 0 ) {
				$items[$user->display_name] = $user->ID;
			}
		}

		ksort( $items );

		return $items;
	}

	/**
	 * Import value to the property.
	 *
	 * @param  mixed  $value
	 * @param  string $slug
	 * @param  int    $post_id
	 *
{'fraction_non_alphanumeric': 0.15528860240257839, 'fraction_numerical': 0.0017579841781423966, 'mean_word_length': 2.548856548856549, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '3620778', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1171, 'n_words': 312}