<commit_before><?php
/**
 * File
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @version 1.2.6
 * @package Phalcon
*/
namespace Phalcon\Http\Request;

use \Phalcon\Http\Request\FileInterface,
	\Phalcon\Http\Request\Exception;

/**
 * Phalcon\Http\Request\File
 *
 * Provides OO wrappers to the $_FILES superglobal
 *
 *<code>
 *	class PostsController extends \Phalcon\Mvc\Controller
 *	{
 *
 *		public function uploadAction()
 *		{
 *			//Check if the user has uploaded files
 *			if ($this->request->hasFiles() == true) {
 *				//Print the real file names and their sizes
 *				foreach ($this->request->getUploadedFiles() as $file){
 *					echo $file->getName(), " ", $file->getSize(), "\n";
 *				}
 *			}
 *		}
 *
 *	}
 *</code>
 * 
 * @see https://github.com/phalcon/cphalcon/blob/1.2.6/ext/http/request/file.c
 */
class File implements FileInterface
{
	/**
	 * Name
	 * 
	 * @var null|string
	 * @access protected
	*/
	protected $_name;

	/**
	 * Temp
	 * 
	 * @var null|string
	 * @access protected
	*/
	protected $_tmp;

	/**
	 * Size
	 * 
	 * @var null|int
	 * @access protected
	*/
	protected $_size;

	/**
	 * Type
	 * 
	 * @var null|string
	 * @access protected
	*/
	protected $_type;

	/**
	 * Error
	 * 
	 * @var null|array
	 * @access protected
	*/
	protected $_error;

	/**
	 * Key
	 * 
	 * @var null|string
	 * @access protected
	*/
	protected $_key;

	/**
	 * \Phalcon\Http\Request\File constructor
	 *
	 * @param array $file
	 * @param string|null $key
	 * @throws Exception
	 */
	public function __construct($file, $key = null)
	{
		if(is_array($file) === false) {
			throw new Exception("Phalcon\\Http\\Request\\File requires a valid uploaded file");
		}

		//@note no type checks
		if(isset($file['name']) === true) {
			$this->_name = (string)$file['name'];
		}

		if(isset($file['tmp_name']) === true) {
			$this->_tmp = (string)$file['tmp_name'];
		}

		if(isset($file['size']) === true) {
			$this->_size = (int)$file['size'];
		}

		if(isset($file['type']) === true) {
			$this->_type = (string)$type;
		}

		if(isset($file['error']) === true) {
			$this->_error = $file['error'];
		}

		if(is_string($key) === true) {
			$this->_key = $key;
		} elseif(is_null($key) === false) {
			throw new Exception('Invalid parameter type.');
		}
	}

	/**
	 * Returns the file size of the uploaded file
	 *
	 * @return int|null
	 */
	public function getSize()
	{<commit_msg>Fixed a variable typo in \Phalcon\Http\Request::__construct().<commit_after><?php
/**
 * File
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @version 1.2.6
 * @package Phalcon
*/
namespace Phalcon\Http\Request;

use \Phalcon\Http\Request\FileInterface,
	\Phalcon\Http\Request\Exception;

/**
 * Phalcon\Http\Request\File
 *
 * Provides OO wrappers to the $_FILES superglobal
 *
 *<code>
 *	class PostsController extends \Phalcon\Mvc\Controller
 *	{
 *
 *		public function uploadAction()
 *		{
 *			//Check if the user has uploaded files
 *			if ($this->request->hasFiles() == true) {
 *				//Print the real file names and their sizes
 *				foreach ($this->request->getUploadedFiles() as $file){
 *					echo $file->getName(), " ", $file->getSize(), "\n";
 *				}
 *			}
 *		}
 *
 *	}
 *</code>
 * 
 * @see https://github.com/phalcon/cphalcon/blob/1.2.6/ext/http/request/file.c
 */
class File implements FileInterface
{
	/**
	 * Name
	 * 
	 * @var null|string
	 * @access protected
	*/
	protected $_name;

	/**
	 * Temp
	 * 
	 * @var null|string
	 * @access protected
	*/
	protected $_tmp;

	/**
	 * Size
	 * 
	 * @var null|int
	 * @access protected
	*/
	protected $_size;

	/**
	 * Type
	 * 
	 * @var null|string
	 * @access protected
	*/
	protected $_type;

	/**
	 * Error
	 * 
	 * @var null|array
	 * @access protected
	*/
	protected $_error;

	/**
	 * Key
	 * 
	 * @var null|string
	 * @access protected
	*/
	protected $_key;

	/**
	 * \Phalcon\Http\Request\File constructor
	 *
	 * @param array $file
	 * @param string|null $key
	 * @throws Exception
	 */
	public function __construct($file, $key = null)
	{
		if(is_array($file) === false) {
			throw new Exception("Phalcon\\Http\\Request\\File requires a valid uploaded file");
		}

		//@note no type checks
		if(isset($file['name']) === true) {
			$this->_name = (string)$file['name'];
		}

		if(isset($file['tmp_name']) === true) {
			$this->_tmp = (string)$file['tmp_name'];
		}

		if(isset($file['size']) === true) {
			$this->_size = (int)$file['size'];
		}

		if(isset($file['type']) === true) {
			$this->_type = (string)$file['type'];
		}

		if(isset($file['error']) === true) {
			$this->_error = $file['error'];
		}

		if(is_string($key) === true) {
			$this->_key = $key;
		} elseif(is_null($key) === false) {
			throw new Exception('Invalid parameter type.');
		}
	}

	/**
	 * Returns the file size of the uploaded file
	 *
	 * @return int|null
	 */
	public function getSize()
	{
{'fraction_non_alphanumeric': 0.1939418581012401, 'fraction_numerical': 0.002439520227688555, 'mean_word_length': 2.9613526570048307, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 49, 'https://': 2, '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': '5811137', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1733, 'n_words': 373}