code: public function withType(string $type): self
      {
          if (empty($type)) {
              throw new \InvalidArgumentException('Expecting a non-empty string.');
          }
  
          $copy = clone $this;
          $copy->type = $type;
          $copy->normalize();
  
          return $copy;
      }
docs: Return a new instance with the specified type.
  
  @param string $type
  @return ResourceObject