<commit_before><?php
/**
 * Class Google\Site_Kit\Core\User_Surveys\REST_User_Surveys_Controller
 *
 * @package   Google\Site_Kit\Core\User_Surveys
 * @copyright 2021 Google LLC
 * @license   https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
 * @link      https://sitekit.withgoogle.com
 */

namespace Google\Site_Kit\Core\User_Surveys;

use Google\Site_Kit\Core\Authentication\Authentication;
use Google\Site_Kit\Core\REST_API\REST_Route;
use WP_REST_Request;
use WP_REST_Server;

/**
 * Class for handling user survey rest routes.
 *
 * @since 1.35.0
 * @access private
 * @ignore
 */
class REST_User_Surveys_Controller {

	/**
	 * Authentication instance.
	 *
	 * @since 1.35.0
	 * @var Authentication
	 */
	protected $authentication;

	/**
	 * Survey_Timeouts isntance.
	 *
	 * @since n.e.x.t
	 * @var Survey_Timeouts
	 */
	protected $timeouts;

	/**
	 * Constructor.
	 *
	 * @since 1.35.0
	 *
	 * @param Authentication  $authentication Authentication instance.
	 * @param Survey_Timeouts $timeouts       User timeouts setting.
	 */
	public function __construct( Authentication $authentication, Survey_Timeouts $timeouts ) {
		$this->authentication = $authentication;
		$this->timeouts       = $timeouts;
	}

	/**
	 * Registers functionality through WordPress hooks.
	 *
	 * @since 1.35.0
	 */
	public function register() {
		add_filter(
			'googlesitekit_rest_routes',
			function ( $routes ) {
				return array_merge( $routes, $this->get_rest_routes() );
			}
		);
	}


	/**
	 * Gets REST route instances.
	 *
	 * @since 1.35.0<commit_msg>Add the survey-timeouts endpoint to preload filter.<commit_after><?php
/**
 * Class Google\Site_Kit\Core\User_Surveys\REST_User_Surveys_Controller
 *
 * @package   Google\Site_Kit\Core\User_Surveys
 * @copyright 2021 Google LLC
 * @license   https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
 * @link      https://sitekit.withgoogle.com
 */

namespace Google\Site_Kit\Core\User_Surveys;

use Google\Site_Kit\Core\Authentication\Authentication;
use Google\Site_Kit\Core\REST_API\REST_Route;
use WP_REST_Request;
use WP_REST_Server;

/**
 * Class for handling user survey rest routes.
 *
 * @since 1.35.0
 * @access private
 * @ignore
 */
class REST_User_Surveys_Controller {

	/**
	 * Authentication instance.
	 *
	 * @since 1.35.0
	 * @var Authentication
	 */
	protected $authentication;

	/**
	 * Survey_Timeouts isntance.
	 *
	 * @since n.e.x.t
	 * @var Survey_Timeouts
	 */
	protected $timeouts;

	/**
	 * Constructor.
	 *
	 * @since 1.35.0
	 *
	 * @param Authentication  $authentication Authentication instance.
	 * @param Survey_Timeouts $timeouts       User timeouts setting.
	 */
	public function __construct( Authentication $authentication, Survey_Timeouts $timeouts ) {
		$this->authentication = $authentication;
		$this->timeouts       = $timeouts;
	}

	/**
	 * Registers functionality through WordPress hooks.
	 *
	 * @since 1.35.0
	 */
	public function register() {
		add_filter(
			'googlesitekit_rest_routes',
			function ( $routes ) {
				return array_merge( $routes, $this->get_rest_routes() );
			}
		);

		add_filter(
			'googlesitekit_apifetch_preload_paths',
			function ( $paths ) {
				return array_merge(
					$paths,
					array(
						'/' . REST_Routes::REST_ROOT . '/core/user/data/survey-timeouts',
					)
				);
			}
		);
	}


	/**
	 * Gets REST route instances.
	 *
	 * @since 1.35.0
{'fraction_non_alphanumeric': 0.12566528681253697, 'fraction_numerical': 0.01655824955647546, 'mean_word_length': 3.2931472081218276, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '934861', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1122, 'n_words': 225}