/**
  * Transforms a collection of recipients into a string
  *
  * @param Collection $recipients
  *
  * @return string
  */
 public function transform($recipients)
 {
     if ($recipients->count() == 0) {
         return "";
     }
     $usernames = array();
     foreach ($recipients as $recipient) {
         $usernames[] = $this->userToUsernameTransformer->transform($recipient);
     }
     return implode(', ', $usernames);
 }
 /**
  * Transforms a collection of UserInterface instances into a list of usernames.
  *
  * @param UserInterface[] $value UserInterface instances
  *
  * @return string|null Usernames
  *
  * @throws UnexpectedTypeException if one of the given value is not a UserInterface instance
  */
 public function transform($value)
 {
     if (null === $value) {
         return null;
     }
     if (!is_array($value) && !$value instanceof \Traversable) {
         throw new UnexpectedTypeException($value, 'array or Traversable');
     }
     $usernames = [];
     foreach ($value as $user) {
         $usernames[] = $this->userToUsernameTransformer->transform($user);
     }
     return implode(', ', $usernames);
 }