Alex\MailCatcher\Message::loadFromArray PHP Method

loadFromArray() public method

public loadFromArray ( array $array ) : Message
$array array
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'])) {
            $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;
    }