Пример #1
0
 /**
  * Get all recipients.
  *
  * @param int $limit  Limit result to given count.
  * @param int $offset Skip certain count of recipients.
  *
  * @return RecipientInterface[]
  */
 public function getRecipients($limit = null, $offset = null)
 {
     if (empty($this->set)) {
         $this->set = array();
         $count = rand($this->minCount, $this->maxCount);
         for ($i = 0; $i < $count; $i++) {
             list($forename, $surname, $name, $domain) = $this->createName();
             $recipient = new MutableRecipient($name . '@' . $domain);
             $recipient->set('forename', $forename);
             $recipient->set('surname', $surname);
             $this->set[] = $recipient;
         }
     }
     $set = $this->set;
     if ($offset > 0) {
         $set = array_slice($set, $offset);
     }
     if ($limit > 0 && $limit < count($set)) {
         $set = array_slice($set, 0, $limit);
     }
     return $set;
 }