<commit_before><?php
namespace suda\framework\http;

use SplFileObject;

/**
 * HTTP请求文件
 */
class UploadedFile extends SplFileObject
{
    /**
     * 上传的文件名
     *
     * @var string
     */
    private $originalName;
    /**
     * 文件的Mimetype
     *
     * @var string
     */
    private $mimeType;
    /**
     * 错误码
     *
     * @var int
     */
    private $error;

    /**
     * 创建文件
     *
     * @param string $path 路径
     * @param string $name 文件名
     * @param string $mimeType mime类型
     * @param integer $error 错误码
     */
    public function __construct(string $path, string $name, string $mimeType = null, int $error = null)
    {
        $this->mimeType = $mimeType ?: 'application/octet-stream';
        $this->error = $error ?: UPLOAD_ERR_OK;
        $this->originalName = pathinfo($name, PATHINFO_FILENAME);
        if ($this->error === UPLOAD_ERR_OK) {
            parent::__construct($path);
        }
    }

    /**
     * Get the value of error
     */
    public function getError()
    {
        return $this->error;
    }

    /**
     * Set the value of error
     *
     * @return  self
     */
    public function setError($error)
    {
        $this->error = $error;

        return $this;
    }

    /**
     * Get the value of mimeType
     */
    public function getMimeType()
    {
        return $this->mimeType;
    }

    /**
     * Set the value of mimeType
     *
     * @return  self
     */
    public function setMimeType($mimeType)
    {
        $this->mimeType = $mimeType;

        return $this;
    }

    /**
     * 判断文件是否可用
     *
     * @return boolean
     */
    public function isValid()
    {
        return UPLOAD_ERR_OK === $this->error && is_uploaded_file($this->getPathname());
    }

    public function __destruct()
    {
        $path = $this->getPathname();
        if (file_exists($path) && is_writeable($path)) {
            unlink($path);
        }
    }

    /**
     * Get 上传的文件名
     *
     * @return  string
     */
    public function getOriginalName()<commit_msg>调整：上传文件控制<commit_after><?php
namespace suda\framework\http;

use SplFileObject;

/**
 * HTTP请求文件
 */
class UploadedFile extends SplFileObject
{
    /**
     * 上传的文件名
     *
     * @var string
     */
    protected $originalName;
    /**
     * 文件的Mimetype
     *
     * @var string
     */
    protected $mimeType;
    /**
     * 错误码
     *
     * @var int
     */
    protected $error;

    /**
     * 创建文件
     *
     * @param string $path 路径
     * @param string $name 文件名
     * @param string $mimeType mime类型
     * @param integer $error 错误码
     */
    public function __construct(string $path, string $name, string $mimeType = null, int $error = null)
    {
        $this->mimeType = $mimeType ?: 'application/octet-stream';
        $this->error = $error ?: UPLOAD_ERR_OK;
        $this->originalName = pathinfo($name, PATHINFO_FILENAME);
        if ($this->error === UPLOAD_ERR_OK) {
            parent::__construct($path);
        }
    }

    /**
     * Get the value of error
     */
    public function getError()
    {
        return $this->error;
    }

    /**
     * Set the value of error
     *
     * @return  self
     */
    public function setError($error)
    {
        $this->error = $error;

        return $this;
    }

    /**
     * Get the value of mimeType
     */
    public function getMimeType()
    {
        return $this->mimeType;
    }

    /**
     * Set the value of mimeType
     *
     * @return  self
     */
    public function setMimeType($mimeType)
    {
        $this->mimeType = $mimeType;

        return $this;
    }

    /**
     * 判断文件是否可用
     *
     * @return boolean
     */
    public function isValid()
    {
        return UPLOAD_ERR_OK === $this->error && is_uploaded_file($this->getPathname());
    }
    
    /**
     * Get 上传的文件名
     *
     * @return  string
     */
    public function getOriginalName()
{'fraction_non_alphanumeric': 0.1293545081967213, 'fraction_numerical': 0.0, 'mean_word_length': 1.6820054945054945, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, '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': '355957', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1331, 'n_words': 272}