<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  /**
   * Handles SOAP Interop requests as proposed by
   * Whitemesa.
   *
   * @see      http://www.whitemesa.com/interop/proposal2.html
   * @purpose  SOAP Interop server
   */
  class Round2Handler extends Object {
  
    /**
     * Echoes a given string.
     *
     * @access  public
     * @param   string 
     * @return  string
     */
    function echoString($inputString) {
      return (string)$inputString;
    }
    
    /**
     * Echoes a given string array.
     *
     * @access  public
     * @param   string[] 
     * @return  string[]
     * @throws  lang.IllegalArgumentException
     */
    function echoStringArray($inputStringArray) {
      if (!$this->_isTypeOf('string',is_array($inputStringArray)) {
        return throw (new IllegalArgumentException('Parameter must be an array ('.xp::typeOf($inputStringArray).' given)');
      }
      
      return $inputStringArray;
    }
    
    /**
     * Echoes an integer
     *
     * @access  public
     * @param   int
     * @return  int
     */
    function echoInteger($inputInteger) {
      return (int)$inputInteger;
    }
    
    /**
     * Echoes an array of integers
     *
     * @access  public
     * @param   int[]
     * @return  int[]
     * @throws  lang.IllegalArgumentException
     */
    function echoIntegerArray($inputIntegerArray) {
      if (!is_array($inputStringArray)) {
        return throw (new IllegalArgumentException('Parameter must be an array ('.xp::typeOf($inputStringArray).' given)');
      }
      
      return $inputIntegerArray;
    }
    
    /**
     * Echoes a float
     *
     * @access  public
     * @param   float
     * @return  float
     */
    function echoFloat($inputFloat) {
      return (float)$inputFloat;
    }
    
    /**
     * Echoes an array of floats
     *
     * @access  public
     * @param   float[]
     * @return  float[]
     * @throws  lang.IllegalArgumentException
     */
    function echoFloatArray($inputFloatArray) {
      if (!is_array($inputStringArray)) {
        return throw (new IllegalArgumentException('Parameter must be an array ('.xp::typeOf($inputStringArray).' given)');
      }
      
      return $inputFloatArray;
    }
    
    /**
     * Echoes a struct.
     *
     * @access  public
     * @param   mixed[] structure
     * @return  mixed[]
     * @throws  lang.IllegalArgumentException
     */
    function echoStruct($inputStruct) {
      if (
        !is_array($inputStruct) ||
        !isset($inputStruct['varString']) ||
        !isset($inputStruct['varInt']) ||
        !isset($inputStruct['varFloat'])
      ) {
        return throw (new IllegalArgumentException('Parameter is not the struct from specification!'));
      }
      
      return $inputStruct;
    }
    
    /**
     * Echoes an array of structs
     *
     * @access  public
     * @param   mixed[]
     * @return  mixed[]
     * @throws  lang.MethodNotImplementedException
     */
    function echoStructArray($inputStructArray) {
      return throw (new MethodNotImplementedException('Not implemented'));
    }
    
    /**
     * Echoes a void.
     *
     * @access  public
     * @return  NULL
     */
    function echoVoid() {
      return NULL;
    }
    
    /**
     * Echoes a base64 string
     *
     * @access  public
     * @param   string
     * @return  string
     * @throws  lang.MethodNotImplementedException
     */
    function echoBase64($inputBase64) {
      return throw (new MethodNotImplementedException('Not implemented'));
    }
    
    /**
     * Echoes a hexbinary.
     *
     * @access  public
     * @param   string 
     * @return  string
     * @throws  lang.MethodNotImplementedException
     */
    function echoHexBinary($inputHexBinary) {
      return throw (new MethodNotImplementedException('Not implemented'));
    }
    
    /**
     * Echoes a date.
     *
     * @access  public
     * @param   &util.Date
     * @return  &util.Date
     * @throws  lang.IllegalArgumentException
     */
    function echoDate($inputDate) {
      if (!is('util.Date', $inputDate)) {
        return throw (new IllegalArgumentException('Given parameter is not a date!'));
      }
      
      return $inputDate;
    }
    
    /**
     * Echoes a decimal.
     *
     * @access  public
     * @param   float
     * @return  float
     */
    function echoDecimal($inputDecimal) {
      return $inputDecimal;
    }
    
    /**
     * Echoes a boolean
     *
     * @access  public
     * @param   boolean
     * @return  boolean
     */
    function echoBoolean($inputBoolean) {
      return (bool)$inputBoolean;
    }
  }
?><commit_msg>- add private methods _assertType(), _assertSubtype() to easily check   for expected argument types.<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  /**
   * Handles SOAP Interop requests as proposed by
   * Whitemesa.
   *
   * @see      http://www.whitemesa.com/interop/proposal2.html
   * @purpose  SOAP Interop server
   */
  class Round2Handler extends Object {

    /**
     * Checks the type of given object.
     *
     * @access  private
     * @param   string type
     * @param   &mixed
     * @throws  lang.IllegalArgumentException
     */
    function _assertType($type, &$object) {
      if ($type != xp::typeOf($object))
        return throw (new IllegalArgumentException('Object not of expected type '.$type.', but '.xp::typeOf($object).' with value '.$object));
    }
    
    /**
     * Checks all entries in an array for correct type
     *
     * @access  private
     * @param   string type
     * @param   &array
     * @
     */
    function _assertSubtype($type, &$array) {
      foreach (array_keys($array) as $key) {
        if ($type != xp::typeOf($array[$key]))
          return throw (new IllegalArgumentException('Object (in array) not of expected type '.$type.', but '.xp::typeOf($array[$key]).' with value '.$array[$key]));
      }
    }
  
    /**
     * Echoes a given string.
     *
     * @access  public
     * @param   string 
     * @return  string
     */
    function echoString($inputString) {
      $this->_assertType('string', $inputString);
      return $inputString;
    }
    
    /**
     * Echoes a given string array.
     *
     * @access  public
     * @param   string[] 
     * @return  string[]
     * @throws  lang.IllegalArgumentException
     */
    function echoStringArray($inputStringArray) {
      $this->_assertType('array', $inputStringArray);
      $this->_assertSubtype('string', $inputStringArray);
      return $inputStringArray;
    }
    
    /**
     * Echoes an integer
     *
     * @access  public
     * @param   int
     * @return  int
     */
    function echoInteger($inputInteger) {
      $this->_assertType('integer', $inputInteger);
      return $inputInteger;
    }
    
    /**
     * Echoes an array of integers
     *
     * @access  public
     * @param   int[]
     * @return  int[]
     * @throws  lang.IllegalArgumentException
     */
    function echoIntegerArray($inputIntegerArray) {
      $this->_assertType('array', $inputIntegerArray);
      $this->_assertSubtype('integer', $inputIntegerArray);
      return $inputIntegerArray;
    }
    
    /**
     * Echoes a float
     *
     * @access  public
     * @param   float
     * @return  float
     */
    function echoFloat($inputFloat) {
      $this->_assertType('float', $inputFloat);
      return $inputFloat;
    }
    
    /**
     * Echoes an array of floats
     *
     * @access  public
     * @param   float[]
     * @return  float[]
     * @throws  lang.IllegalArgumentException
     */
    function echoFloatArray($inputFloatArray) {
      $this->_assertType('array', $inputFloatArray);
      $this->_assertSubtype('float', $inputFloatArray);
      return $inputFloatArray;
    }
    
    /**
     * Echoes a struct.
     *
     * @access  public
     * @param   mixed[] structure
     * @return  mixed[]
     * @throws  lang.IllegalArgumentException
     */
    function echoStruct($inputStruct) {
      $this->_assertType('array',   $inputStruct);
      $this->_assertType('string',  $inputStruct['varString']);
      $this->_assertType('integer', $inputStruct['varInt']);
      $this->_assertType('float',   $inputStruct['varFloat']);
      return $inputStruct;
    }
    
    /**
     * Echoes an array of structs
     *
     * @access  public
     * @param   mixed[]
     * @return  mixed[]
     * @throws  lang.MethodNotImplementedException
     */
    function echoStructArray($inputStructArray) {
      return throw (new MethodNotImplementedException('Not implemented'));
    }
    
    /**
     * Echoes a void.
     *
     * @access  public
     * @return  NULL
     */
    function echoVoid() {
      return NULL;
    }
    
    /**
     * Echoes a base64 string
     *
     * @access  public
     * @param   string
     * @return  string
     * @throws  lang.MethodNotImplementedException
     */
    function echoBase64($inputBase64) {
      return throw (new MethodNotImplementedException('Not implemented'));
    }
    
    /**
     * Echoes a hexbinary.
     *
     * @access  public
     * @param   string 
     * @return  string
     * @throws  lang.MethodNotImplementedException
     */
    function echoHexBinary($inputHexBinary) {
      return throw (new MethodNotImplementedException('Not implemented'));
    }
    
    /**
     * Echoes a date.
     *
     * @access  public
     * @param   &util.Date
     * @return  &util.Date
     * @throws  lang.IllegalArgumentException
     */
    function echoDate($inputDate) {
      $this->_assertType('util.Date', $inputType);
      return $inputDate;
    }
    
    /**
     * Echoes a decimal.
     *
     * @access  public
     * @param   float
     * @return  float
     */
    function echoDecimal($inputDecimal) {
      $this->_assertType('float', $inputDecimal);
      return $inputDecimal;
    }
    
    /**
     * Echoes a boolean
     *
     * @access  public
     * @param   boolean
     * @return  boolean
     */
    function echoBoolean($inputBoolean) {
      $this->_assertType('boolean', $inputBoolean);
      return (bool)$inputBoolean;
    }
  }
?>
{'fraction_non_alphanumeric': 0.12174338883447601, 'fraction_numerical': 0.0015670910871694416, 'mean_word_length': 2.054442117858211, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1089579', 'n_tokens_mistral': 3054, 'n_tokens_neox': 2986, 'n_words': 672}