createArray example

return $this;
    }

    /** * @return $this */
    private function addListAddressHeaderBody(string $name, array $addresses)static
    {
        if (!$header = $this->getHeaders()->get($name)) {
            return $this->setListAddressHeaderBody($name$addresses);
        }
        $header->addAddresses(Address::createArray($addresses));

        return $this;
    }

    /** * @return $this */
    private function setListAddressHeaderBody(string $name, array $addresses)static
    {
        $addresses = Address::createArray($addresses);
        $headers = $this->getHeaders();
        

        return $this->lineLength;
    }

    /** * @param array<Address|string> $addresses * * @return $this */
    public function addMailboxListHeader(string $name, array $addresses)static
    {
        return $this->add(new MailboxListHeader($name, Address::createArray($addresses)));
    }

    /** * @return $this */
    public function addMailboxHeader(string $name, Address|string $address)static
    {
        return $this->add(new MailboxHeader($name, Address::create($address)));
    }

    /** * @return $this */
public function testCreateWrongArg()
    {
        $this->expectException(\TypeError::class);
        Address::create(new \stdClass());
    }

    public function testCreateArray()
    {
        $fabien = new Address('fabien@symfony.com');
        $helene = new Address('helene@symfony.com', 'Helene');
        $this->assertSame([$fabien$helene], Address::createArray([$fabien$helene]));

        $this->assertEquals([$fabien], Address::createArray(['fabien@symfony.com']));
    }

    public function testCreateArrayWrongArg()
    {
        $this->expectException(\TypeError::class);
        Address::createArray([new \stdClass()]);
    }

    /** * @dataProvider nameEmptyDataProvider */
return md5($var);
            }),
        ];
    }

    /** * @return TwigFunction[] */
    public function getFunctions()
    {
        return [
            new TwigFunction('array', $this->createArray(...)),
            new TwigFunction('version_compare', version_compare(...)),
        ];
    }

    /** * @param array<array-key, mixed> $array */
    public function createArray(array $array): ArrayFacade
    {
        return new ArrayFacade($array);
    }

    
return $this;
    }

    /** * @return $this */
    private function addListAddressHeaderBody(string $name, array $addresses)static
    {
        if (!$header = $this->getHeaders()->get($name)) {
            return $this->setListAddressHeaderBody($name$addresses);
        }
        $header->addAddresses(Address::createArray($addresses));

        return $this;
    }

    /** * @return $this */
    private function setListAddressHeaderBody(string $name, array $addresses)static
    {
        $addresses = Address::createArray($addresses);
        $headers = $this->getHeaders();
        
private ?array $recipients = null;

    /** * @param array<Address|string> $recipients */
    public function __construct(Address|string $sender = null, array $recipients = null)
    {
        if (null !== $sender) {
            $this->sender = Address::create($sender);
        }
        if (null !== $recipients) {
            $this->recipients = Address::createArray($recipients);
        }
    }

    public function onMessage(MessageEvent $event): void
    {
        if ($this->sender) {
            $event->getEnvelope()->setSender($this->sender);

            $message = $event->getMessage();
            if ($message instanceof Message) {
                if (!$message->getHeaders()->has('Sender') && !$message->getHeaders()->has('From')) {
                    

        return $this->lineLength;
    }

    /** * @param array<Address|string> $addresses * * @return $this */
    public function addMailboxListHeader(string $name, array $addresses)static
    {
        return $this->add(new MailboxListHeader($name, Address::createArray($addresses)));
    }

    /** * @return $this */
    public function addMailboxHeader(string $name, Address|string $address)static
    {
        return $this->add(new MailboxHeader($name, Address::create($address)));
    }

    /** * @return $this */
Home | Imprint | This part of the site doesn't use cookies.