<?php


namespace CMSMSExt\core;


class api_base
{
  private $_options = [];
  private $_target   = [];
  
  private function extend(array  $options)
  {
    $this->_options = \array_merge($this->_options, $options);
  }
  
  private function init()
  {
    $this->_options = []; // override this method in child classes with the default options
  }
  
  public function __construct($target = NULL, &$options = [])
  {
    $this->_target = $target;
    $this->_options = \array_merge($this->_options, $options);
  }
  
  public function __call($name, $arguments)
  {
    if( !\startswith($name,  '_') && \method_exists($this, $name) )
    {
      return \call_user_func_array([$this, $name], $arguments);
    }
    
    throw new \BadMethodCallException($name);
  }
  
}
?>