code: private function encodeValue($value, Field $field)
      {
          $type = $field->getType();
  
          if ($type->encodesToScalar()) {
              if ($type->isString()) {
                  $value = $type->encode($value, $field, $this);
                  if (empty($value)) {
                      return ['NULL' => true];
                  } else {
                      return [self::TYPE_STRING => $value];
                  }
              } elseif ($type->isNumeric()) {
                  return [self::TYPE_NUMBER => (string)$type->encode($value, $field, $this)];
              } elseif ($type->isBoolean()) {
                  return ['BOOL' => $type->encode($value, $field, $this)];
              } elseif ($type->isBinary()) {
                  $value = $type->encode($value, $field, $this);
                  if (empty($value)) {
                      return ['NULL' => true];
                  } else {
                      return [self::TYPE_BINARY => $value];
                  }
              }
  
              throw new EncodeValueFailed($value, $field, get_called_class() . ' has no handling for this value.');
          }
  
          return $type->encode($value, $field, $this);
      }
docs: @param mixed $value
  @param Field $field
  
  @return mixed
  
  @throws EncodeValueFailed