<commit_before><?php
namespace zeus\domain;
use zeus\base\AbstractComponent;
use zeus\base\logger\Logger;

/**
 * Created by IntelliJ IDEA.
 * User: nathena
 * Date: 2017/6/2
 * Time: 19:25
 */

abstract class AbstractEntity extends AbstractComponent
{
    protected $data = [];
    protected $id;

    private $idFiled;//uuid key
    private $update_data = [];//更新未来提交的数据


    public function __construct($data,$idFiled='id'){

        if(!empty($data) && is_array($data)){
            $this->data = $data;
            if(isset($data[$idFiled])){
                $this->id = trim($data[$idFiled]);
            }
        }
        $this->idFiled = $idFiled;
    }


    public function getId(){
        return $this->id;
    }

    public function getData(){
        return $this->data;
    }

    /**
     * 不允许更新id
     * @param mixed|array $data
     */
    public function setData($data){
        //不允许更新id
        if(isset($data[$this->idFiled])){
            Logger::debug(self::class." {$this->id} setData unset {$data[$this->idFiled]} ");
            unset($data[$this->idFiled]);

        }

        $this->data = array_merge($this->data,$data);
        $this->update_data = array_merge($this->update_data,$data);
    }

    public function updateData(){
        $data = $this->update_data;
        $this->update_data = [];

        return $data;
    }

    public function __get($key){
        if(isset($this->data[$key])){
            return $this->data[$key];
        }
        return '';
    }

    public function __set($key,$val){
        //不允许更新id
        if($key == $this->idFiled){
            return;
        }
        $this->data[$key] = $val;
        $this->update_data[$key] = $val;
    }
}<commit_msg>change format<commit_after><?php

namespace zeus\domain;

use zeus\base\AbstractComponent;
use zeus\base\logger\Logger;

/**
 * Created by IntelliJ IDEA.
 * User: nathena
 * Date: 2017/6/2
 * Time: 19:25
 */
abstract class AbstractEntity extends AbstractComponent
{
    protected $data = [];
    protected $id;

    private $idFiled;//uuid key
    private $update_data = [];//更新未来提交的数据

    public function __construct($data, $idFiled = 'id')
    {

        if (!empty($data) && is_array($data)) {
            $this->data = $data;
            if (isset($data[$idFiled])) {
                $this->id = trim($data[$idFiled]);
            }
        }
        $this->idFiled = $idFiled;
    }

    public function getId()
    {
        return $this->id;
    }

    public function getData()
    {
        return $this->data;
    }

    /**
     * 不允许更新id
     * @param mixed|array $data
     */
    public function setData($data)
    {
        //不允许更新id
        if (isset($data[$this->idFiled])) {
            Logger::debug(self::class . " {$this->id} setData unset {$data[$this->idFiled]} ");
            unset($data[$this->idFiled]);
        }

        $this->data = array_merge($this->data, $data);
        $this->update_data = array_merge($this->update_data, $data);
    }

    public function updateData()
    {
        $data = $this->update_data;
        $this->update_data = [];

        return $data;
    }

    public function __get($key)
    {
        if (isset($this->data[$key])) {
            return $this->data[$key];
        }
        return '';
    }

    public function __set($key, $val)
    {
        //不允许更新id
        if ($key == $this->idFiled) {
            return;
        }
        $this->data[$key] = $val;
        $this->update_data[$key] = $val;
    }
}
{'fraction_non_alphanumeric': 0.1662382176520994, 'fraction_numerical': 0.0057126535275635534, 'mean_word_length': 1.9804255319148936, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '5876125', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1153, 'n_words': 209}