original_string: public function cast($value, $type)
      {
          if (is_string($type)) {
              $type = Type::build($type);
          }
          if ($type instanceof TypeInterface) {
              $value = $type->toDatabase($value, $this->_driver);
              $type = $type->toStatement($value, $this->_driver);
          }
  
          return [$value, $type];
      }
code: public function cast($value, $type)
      {
          if (is_string($type)) {
              $type = Type::build($type);
          }
          if ($type instanceof TypeInterface) {
              $value = $type->toDatabase($value, $this->_driver);
              $type = $type->toStatement($value, $this->_driver);
          }
  
          return [$value, $type];
      }
code_tokens: public function cast ( $ value , $ type ) { if ( is_string ( $ type ) ) { $ type = Type :: build ( $ type ) ; } if ( $ type instanceof TypeInterface ) { $ value = $ type -> toDatabase ( $ value , $ this -> _driver ) ; $ type = $ type -> toStatement ( $ value , $ this -> _driver ) ; } return [ $ value , $ type ] ; }
docstring: Converts a give value to a suitable database value based on type
  and return relevant internal statement type
  
  @param mixed $value The value to cast
  @param \Cake\Database\Type|string $type The type name or type instance to use.
  @return array list containing converted value and internal type
docstring_tokens: Converts a give value to a suitable database value based on type and return relevant internal statement type