protected function onSetAttribute($name, $value) {
    // Listen to these attributes
    $listen = [
      'message_type'=> 'type',
      'message_id'  => 'id',
      'credits_cost'=> 'credits',
      'rb_cost'     => 'cost',
    ];
    // If set
    if (isset($listen[$name])) {
      // If not yet set
      if ( ! isset($this->{$listen[$name]})) {
        // Set corresponding attribute
        $this->{$listen[$name]} = $value;
      }
    }
  }
protected function onSetAttribute($name, $value) {
    // Listen to these attributes
    $listen = [
      'message_type'=> 'type',
      'message_id'  => 'id',
      'credits_cost'=> 'credits',
      'rb_cost'     => 'cost',
    ];
    // If set
    if (isset($listen[$name])) {
      // If not yet set
      if ( ! isset($this->{$listen[$name]})) {
        // Set corresponding attribute
        $this->{$listen[$name]} = $value;
      }
    }
  }
protected function onSetAttribute ( $ name , $ value ) { // Listen to these attributes $ listen = [ 'message_type' => 'type' , 'message_id' => 'id' , 'credits_cost' => 'credits' , 'rb_cost' => 'cost' , ] ; // If set if ( isset ( $ listen [ $ name ] ) ) { // If not yet set if ( ! isset ( $ this -> { $ listen [ $ name ] } ) ) { // Set corresponding attribute $ this -> { $ listen [ $ name ] } = $ value ; } } }
When an attribute is set
When an attribute is set