code: public function serialize($value)
      {
          if ($value === true) {
              return 'true';
          }
          if ($value === false) {
              return 'false';
          }
          if ($value === null) {
              return 'null';
          }
          if (is_object($value) && method_exists($value, '__toString')) {
              return (string) $value;
          }
          if (! is_scalar($value)) {
              throw new Error('String cannot represent non scalar value: ' . Utils::printSafe($value));
          }
  
          return $this->coerceString($value);
      }
docs: @param mixed $value
  
  @return mixed|string
  
  @throws Error