code: public static function processAttachments(array $attachments)
      {
          $processed = [];
  
          foreach ($attachments as $attachment) {
              if (!($attachment instanceof Attachment)) {
                  throw new \InvalidArgumentException('Attachments must implement Stampie\\Attachment');
              }
  
              $name = $attachment->getName();
  
              if (isset($processed[$name])) {
                  // Name conflict
                  $name = static::findUniqueName($name, array_keys($processed));
              }
  
              $processed[$name] = $attachment;
          }
  
          return $processed;
      }
docs: Applies a function to each attachment, and finds a unique name for any conflicting names.
  
  @param Attachment[] $attachments
  
  @throws \InvalidArgumentException
  
  @return Attachment[]