<commit_before><?php

/**
 * Message
 *
 * Pass cross-requests messages.
 * 
 * @package core
 * @author <EMAIL>
 * @version 1.0
 * @copyright Caffeina srl - 2014 - http://caffeina.co
 */

class Message extends Dictionary {

  protected static $loaded = false;
  protected static $fields = [];

  protected static function init(){
    if(false===static::$loaded){
      static::load(Session::get('_messages',[]));
      static::$loaded = true;
    }
  }

  public static function & get($key,$default=null){
    static::init();
    $value = parent::get($key,'');
    parent::delete($key,'');
    Session::set('_messages',parent::all());
    return $value;
  }

  public static function set($key,$data=null){
    static::init();
    parent::set($key,$data);
    return Session::set('_messages',parent::all());
  }

  public static function add($key,$data=null){
    static::init();
    $d = parent::get($key,[]);
    $d[] = $data;
    parent::set($key,$d);
    return Session::set('_messages',parent::all());
  }

  public static function & all(){
    static::init();
    $all = parent::all();
    static::clear();<commit_msg>[Message] `all` method single extraction<commit_after><?php

/**
 * Message
 *
 * Pass cross-requests messages.
 * 
 * @package core
 * @author <EMAIL>
 * @version 1.0
 * @copyright Caffeina srl - 2014 - http://caffeina.co
 */

class Message extends Dictionary {

  protected static $loaded = false;
  protected static $fields = [];

  protected static function init(){
    if(false===static::$loaded){
      static::load(Session::get('_messages',[]));
      static::$loaded = true;
    }
  }

  public static function & get($key,$default=null){
    static::init();
    $value = parent::get($key,'');
    parent::delete($key,'');
    Session::set('_messages',parent::all());
    return $value;
  }

  public static function set($key,$data=null){
    static::init();
    parent::set($key,$data);
    return Session::set('_messages',parent::all());
  }

  public static function add($key,$data=null){
    static::init();
    $d = parent::get($key,[]);
    $d[] = $data;
    parent::set($key,$d);
    return Session::set('_messages',parent::all());
  }

  public static function & all($key=null){
    static::init();
    if($key){
      $all = static::get($key,[]);
    } else {
      $all = parent::all();
      static::clear();
    }
{'fraction_non_alphanumeric': 0.2028862478777589, 'fraction_numerical': 0.0050933786078098476, 'mean_word_length': 3.6673267326732675, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '6844124', 'n_tokens_mistral': 753, 'n_tokens_neox': 732, 'n_words': 155}