示例#1
0
 /**
  * @return Message
  */
 public function loadFromArray(array $array)
 {
     if (isset($array['id'])) {
         $this->id = $array['id'];
     }
     if (isset($array['created_at'])) {
         $this->createdAt = new \DateTime($array['created_at']);
     }
     if (isset($array['size'])) {
         $this->size = $array['size'];
     }
     if (isset($array['subject'])) {
         $this->subject = $array['subject'];
     }
     if (isset($array['sender'])) {
         $this->sender = Person::createFromString($array['sender']);
     }
     if (isset($array['recipients'])) {
         $this->recipients = array_map(function ($string) {
             return Person::createFromString($string);
         }, $array['recipients']);
     }
     if (isset($array['formats'])) {
         $this->formats = $array['formats'];
     }
     if (isset($array['type'])) {
         $this->type = $array['type'];
     }
     if (isset($array['attachments'])) {
         $attachments = $array['attachments'];
         $client = $this->client;
         $this->attachments = array_map(function ($array) use($client) {
             return new Attachment($client, $array);
         }, $array['attachments']);
     }
     if (isset($array['source'])) {
         $this->loadSource($array['source']);
     }
     return $this;
 }
示例#2
0
 /**
  * @dataProvider provideCorrect
  */
 public function testCorrect($string, $name, $email)
 {
     $person = Person::createFromString($string);
     $this->assertEquals($email, $person->getEmail(), "Email is correct");
     $this->assertEquals($name, $person->getName(), "Name is correct");
 }