getAddressStrings example

use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Header\MailboxListHeader;

class MailboxListHeaderTest extends TestCase
{
    // RFC 2822, 3.6.2 for all tests
    public function testMailboxIsSetForAddress()
    {
        $header = new MailboxListHeader('From', [new Address('chris@swiftmailer.org')]);
        $this->assertEquals(['chris@swiftmailer.org']$header->getAddressStrings());
    }

    public function testMailboxIsRenderedForNameAddress()
    {
        $header = new MailboxListHeader('From', [new Address('chris@swiftmailer.org', 'Chris Corbyn')]);
        $this->assertEquals(['Chris Corbyn <chris@swiftmailer.org>']$header->getAddressStrings());
    }

    public function testAddressCanBeReturnedForAddress()
    {
        $header = new MailboxListHeader('From', $addresses = [new Address('chris@swiftmailer.org')]);
        
if ($name = $address->getName()) {
                $str = $this->createPhrase($this$name$this->getCharset(), !$strings).' <'.$str.'>';
            }
            $strings[] = $str;
        }

        return $strings;
    }

    public function getBodyAsString(): string
    {
        return implode(', ', $this->getAddressStrings());
    }

    /** * Redefine the encoding requirements for addresses. * * All "specials" must be encoded as the full header value will not be quoted * * @see RFC 2822 3.2.1 */
    protected function tokenNeedsEncoding(string $token): bool
    {
        
if ($name = $address->getName()) {
                $str = $this->createPhrase($this$name$this->getCharset(), !$strings).' <'.$str.'>';
            }
            $strings[] = $str;
        }

        return $strings;
    }

    public function getBodyAsString(): string
    {
        return implode(', ', $this->getAddressStrings());
    }

    /** * Redefine the encoding requirements for addresses. * * All "specials" must be encoded as the full header value will not be quoted * * @see RFC 2822 3.2.1 */
    protected function tokenNeedsEncoding(string $token): bool
    {
        
Home | Imprint | This part of the site doesn't use cookies.