<commit_before><?php

/**
 * Basic implementation of the Ruby on Rails ActiveResource REST client.
 * Intended to work with RoR-based REST servers, which all share similar
 * API patterns.
 *
 * Usage:
 *
 *     <?php
 *     
 *     require_once ('ActiveResource.php');
 *     
 *     class Song extends ActiveResource {
 *         var $site = 'http://localhost:3000/';
 *         var $element_name = 'songs';
 *     }
 *     
 *     // create new item
 *     $song = new Song (array ('artist' => '<NAME>', 'title' => 'A Little Help From My Friends'));
 *     $song->save ();
 *     
 *     // fetch and update an item
 *     $song->find (44)->set ('title', 'The River')->save ();
 *     
 *     // line by line
 *     $song->find (44);
 *     $song->title = 'The River';
 *     $song->save ();
 *     
 *     // get all songs
 *     $songs = $song->find ('all');
 *     
 *     // delete a song
 *     $song->find (44);
 *     $song->destroy ();
 *     
 *     // custom method
 *     $songs = $song->get ('by_year', array ('year' => 1999));
 *     
 *     ?>
 *
 * @author <NAME> <<EMAIL>>
 * @version 0.14 beta
 * @license http://opensource.org/licenses/lgpl-2.1.php
 */
class ActiveResource {
	/**
	 * The REST site address, e.g., `http://user:pass@domain:port/`
	 */
	public $site = false;

	/**
	 * Add any extra params to the end of the url eg: API key
	 */
	public $extra_params = false;

	/**
	 * HTTP Basic Authentication user
	 */
	public $user = null;

	/**
	 * HTTP Basic Authentication password
	 */	
	public $password = <PASSWORD>;
	
	/**
	 * The remote collection, e.g., person or thing
	 */
	public $element_name = false;

	/**
	 * Pleural form of the element name, e.g., people or things
	 */
	public $element_name_plural = '';

	/**
	 * The data of the current object, accessed via the anonymous get/set methods.
	 */
	private $_data = array ();

	/**
	 * An error message if an error occurred.
	 */
	public $error = false;

	/**
	 * The error number if an error occurred.
	 */
	public $errno = false;

	/**
	 * The request that was sent to the server.
	 */
	public $request_body = '';

	/**
	 * The complete URL that the request was sent to.
	 */
	public $request_uri = '';

	/**
	 * The request method sent to the server.
	 */
	public $request_method = '';

	/**
	 * The response code returned from the server.
	 */
	public $response_code = false;

	/**
	 * The raw response headers sent from the server.
	 */
	public $response_headers = '';

	/**
	 * The response body sent from the server.
	 */
	public $response_body = '';

	/**
	 * The format requests should use to send data (url or xml).
	 */
	public $request_format = 'url';

	/**
	 * Corrections to improper pleuralizations.
	 */
	public $pleural_corrections = array (
		'persons' => 'people',
		'peoples' => 'people',
		'mans' => 'men',
		'mens' => 'men',
		'womans' => 'women',
		'womens' => 'women',
		'childs' => 'children',
		'childrens' => 'children',
		'sheeps' => 'sheep',
		'octopuses' => 'octopi',
		'quizs' => 'quizzes',
		'axises' => 'axes',
		'buffalos' => 'buffaloes',
		'tomatos' => 'tomatoes',
		'potatos' => 'potatoes',
		'oxes' => 'oxen',
		'mouses' => 'mice',
		'matrixes' => 'matrices',
		'vertexes' => 'vertices',
		'indexes' => 'indices',
	);

	/**
	 * Constructor method.
	 */
	public function __construct ($data = array ()) {
		$this->_data = $data;
		// Allow class-defined element name or use class name if not defined
		$this->element_name = $this->element_name ? $this->element_name : strtolower (get_class ($this));
		$this->element_name_plural = $this->pluralize ($this->element_name);

		// Detect for namespaces, and take just the class name
		if (stripos($this->element_name, '\\'))
		{
			$classItems = explode('\\', $this->element_name);
			$this->element_name = end($classItems);
		}

		// If configuration file (`config.ini.php`) exists use it (overwrite class properties/attribute values).
		$config_file_path = dirname (__FILE__) . '/' . 'config.ini.php';
		if (file_exists ($config_file_path)) {
			$properties = parse_ini_file ($config_file_path);
			foreach ($properties as $property => $value )
				$this->{$property} = $value;
		}
	}

	/**
	 * Pluralize the element name.
	 */
	public function pluralize ($word) {
		$word .= 's';
		$word = preg_replace ('/(x|ch|sh|ss])s$/', '\1es', $word);
		$word = preg_replace ('/ss$/', 'ses', $word);
		$word = preg_replace ('/([ti])ums$/', '\1a', $word);
		$word = preg_replace ('/sises$/', 'ses', $word);
		$word = preg_replace ('/([^aeiouy]|qu)ys$/', '\1ies', $word);
		$word = preg_replace ('/(?:([^f])fe|([lr])f)s$/', '\1\2ves', $word);
		$word = preg_replace ('/ieses$/', 'ies', $word);
		if (isset ($this->pleural_corrections[$word])) {
			return $this->pleural_corrections[$word];
		}
		return $word;
	}<commit_msg>Updated ActiveResource in lib/vendor<commit_after><?php

/**
 * Basic implementation of the Ruby on Rails ActiveResource REST client.
 * Intended to work with RoR-based REST servers, which all share similar
 * API patterns.
 *
 * Usage:
 *
 *     <?php
 *     
 *     require_once ('ActiveResource.php');
 *     
 *     class Song extends ActiveResource {
 *         var $site = 'http://localhost:3000/';
 *         var $element_name = 'songs';
 *     }
 *     
 *     // create new item
 *     $song = new Song (array ('artist' => '<NAME>', 'title' => 'A Little Help From My Friends'));
 *     $song->save ();
 *     
 *     // fetch and update an item
 *     $song->find (44)->set ('title', 'The River')->save ();
 *     
 *     // line by line
 *     $song->find (44);
 *     $song->title = 'The River';
 *     $song->save ();
 *     
 *     // get all songs
 *     $songs = $song->find ('all');
 *     
 *     // delete a song
 *     $song->find (44);
 *     $song->destroy ();
 *     
 *     // custom method
 *     $songs = $song->get ('by_year', array ('year' => 1999));
 *     
 *     ?>
 *
 * @author <NAME> <<EMAIL>>
 * @version 0.14 beta
 * @license http://opensource.org/licenses/lgpl-2.1.php
 */
class ActiveResource {
	/**
	 * The REST site address, e.g., `http://user:pass@domain:port/`
	 */
	public $site = false;

	/**
	 * Add any extra params to the end of the url eg: API key
	 */
	public $extra_params = false;

	/**
	 * HTTP Basic Authentication user
	 */
	public $user = null;

	/**
	 * HTTP Basic Authentication password
	 */	
	public $password = <PASSWORD>;
	
	/**
	 * The remote collection, e.g., person or thing
	 */
	public $element_name = false;

	/**
	 * Pleural form of the element name, e.g., people or things
	 */
	public $element_name_plural = '';

	/**
	 * The data of the current object, accessed via the anonymous get/set methods.
	 */
	private $_data = array ();

	/**
	 * An error message if an error occurred.
	 */
	public $error = false;

	/**
	 * The error number if an error occurred.
	 */
	public $errno = false;

	/**
	 * The request that was sent to the server.
	 */
	public $request_body = '';

	/**
	 * The complete URL that the request was sent to.
	 */
	public $request_uri = '';

	/**
	 * The request method sent to the server.
	 */
	public $request_method = '';

	/**
	 * The response code returned from the server.
	 */
	public $response_code = false;

	/**
	 * The raw response headers sent from the server.
	 */
	public $response_headers = '';

	/**
	 * The response body sent from the server.
	 */
	public $response_body = '';

	/**
	 * The format requests should use to send data (url or xml).
	 */
	public $request_format = 'url';

	/**
	 * Corrections to improper pleuralizations.
	 */
	public $pleural_corrections = array (
		'persons' => 'people',
		'peoples' => 'people',
		'mans' => 'men',
		'mens' => 'men',
		'womans' => 'women',
		'womens' => 'women',
		'childs' => 'children',
		'childrens' => 'children',
		'sheeps' => 'sheep',
		'octopuses' => 'octopi',
		'quizs' => 'quizzes',
		'axises' => 'axes',
		'buffalos' => 'buffaloes',
		'tomatos' => 'tomatoes',
		'potatos' => 'potatoes',
		'oxes' => 'oxen',
		'mouses' => 'mice',
		'matrixes' => 'matrices',
		'vertexes' => 'vertices',
		'indexes' => 'indices',
	);

	/**
	 * Constructor method.
	 */
	public function __construct ($data = array ()) {
		$this->_data = $data;
		// Allow class-defined element name or use class name if not defined
		$this->element_name = $this->element_name ? $this->element_name : strtolower (get_class ($this));

		// Detect for namespaces, and take just the class name
		if (stripos ($this->element_name, '\\')) {
			$classItems = explode ('\\', $this->element_name);
			$this->element_name = end ($classItems);
		}

		// Get the plural name after removing namespaces
		$this->element_name_plural = $this->pluralize ($this->element_name);

		// If configuration file (`config.ini.php`) exists use it (overwrite class properties/attribute values).
		$config_file_path = dirname (__FILE__) . '/' . 'config.ini.php';
		if (file_exists ($config_file_path)) {
			$properties = parse_ini_file ($config_file_path);
			foreach ($properties as $property => $value )
				$this->{$property} = $value;
		}
	}

	/**
	 * Pluralize the element name.
	 */
	public function pluralize ($word) {
		$word .= 's';
		$word = preg_replace ('/(x|ch|sh|ss])s$/', '\1es', $word);
		$word = preg_replace ('/ss$/', 'ses', $word);
		$word = preg_replace ('/([ti])ums$/', '\1a', $word);
		$word = preg_replace ('/sises$/', 'ses', $word);
		$word = preg_replace ('/([^aeiouy]|qu)ys$/', '\1ies', $word);
		$word = preg_replace ('/(?:([^f])fe|([lr])f)s$/', '\1\2ves', $word);
		$word = preg_replace ('/ieses$/', 'ies', $word);
		if (isset ($this->pleural_corrections[$word])) {
			return $this->pleural_corrections[$word];
		}
		return $word;
	}
{'fraction_non_alphanumeric': 0.18654085441725426, 'fraction_numerical': 0.004977187888842804, 'mean_word_length': 2.856457417033187, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4768618', 'n_tokens_mistral': 3519, 'n_tokens_neox': 3198, 'n_words': 902}