/**
  * Test construction with parameters
  *
  * @return void
  */
 public function testConstructWithParameters()
 {
     $parameters = ['a' => ['type' => 'float', 'in' => true], 'b' => ['type' => 'float', 'in' => true]];
     $method = new Method('CALC.SUM', $parameters);
     $this->assertEquals(['a', 'b'], $method->parameters());
 }
 /**
  * Convert parameter description results into abstract schema fields.
  *
  * @param \CakeDC\OracleDriver\Database\Schema\Method $method The method object to append parameters to.
  * @param array $row The row data from `describeParametersSql`.
  * @return void
  */
 public function convertParametersDescription(Method $method, $row)
 {
     $row = array_change_key_case($row);
     switch ($row['type']) {
         case 'DATE':
             $field = ['type' => 'datetime', 'length' => null];
             break;
         case 'TIMESTAMP':
         case 'TIMESTAMP(6)':
         case 'TIMESTAMP(9)':
             $field = ['type' => 'timestamp', 'length' => null];
             break;
         case 'NUMBER':
         case 'INTEGER':
         case 'PLS_INTEGER':
         case 'BINARY_INTEGER':
             if ($row['data_precision'] == 1) {
                 $field = ['type' => 'boolean', 'length' => null];
             } elseif ($row['data_scale'] > 0) {
                 $field = ['type' => 'decimal', 'length' => $row['data_precision'], 'precision' => $row['data_scale']];
             } else {
                 $field = ['type' => 'integer', 'length' => $row['data_precision']];
             }
             break;
         case 'FLOAT':
         case 'BINARY_FLOAT':
         case 'BINARY_DOUBLE':
             $field = ['type' => 'float', 'length' => $row['data_precision']];
             break;
         case 'NCHAR':
         case 'NVARCHAR2':
         case 'CHAR':
         case 'VARCHAR2':
         case 'LONG':
         case 'ROWID':
         case 'UROWID':
             $length = $row['data_length'];
             if ($length == 36) {
                 $field = ['type' => 'uuid', 'length' => null];
             } else {
                 $field = ['type' => 'string', 'length' => $length];
             }
             break;
         case 'NCLOB':
         case 'CLOB':
             $field = ['type' => 'text', 'length' => $row['data_length']];
             break;
         case 'RAW':
         case 'LONG RAW':
         case 'BLOB':
             $field = ['type' => 'binary', 'length' => $row['data_length']];
             break;
         case 'REF CURSOR':
             $field = ['type' => 'cursor'];
             break;
         default:
     }
     $out = strpos($row['direction'], 'OUT') !== false ? true : false;
     $name = $row['name'];
     $function = $out && $name === null ? true : false;
     $field += ['in' => strpos($row['direction'], 'IN') !== false ? true : false, 'out' => $out, 'function' => $function];
     if ($function) {
         $name = ':result';
     }
     $method->addParameter($name, $field);
 }
 /**
  * Apply schema structure to the request object.
  *
  * @param MethodSchema $schema Method schema object instance.
  * @return void
  */
 public function applySchema(MethodSchema $schema)
 {
     $parameters = $schema->parameters();
     foreach ($parameters as $name) {
         $parameter = $schema->parameter($name);
         if ($parameter['in']) {
             $this->set($name, null);
             // @todo default ???
         }
         if ($parameter['out']) {
             $this->set($name, null);
         }
     }
 }