Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
5.00% covered (danger)
5.00%
1 / 20
CRAP
7.89% covered (danger)
7.89%
3 / 38
WrappedTemplatedEmail
0.00% covered (danger)
0.00%
0 / 1
5.00% covered (danger)
5.00%
1 / 20
436.34
7.89% covered (danger)
7.89%
3 / 38
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 toName
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 image
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 5
 attach
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 5
 setSubject
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getSubject
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 setReturnPath
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getReturnPath
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 addFrom
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getFrom
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 addReplyTo
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getReplyTo
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 addTo
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getTo
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 addCc
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getCc
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 addBcc
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getBcc
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setPriority
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getPriority
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
<?php
/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Symfony\Bridge\Twig\Mime;
use Symfony\Component\Mime\Address;
use Twig\Environment;
/**
 * @internal
 *
 * @author Fabien Potencier <fabien@symfony.com>
 */
final class WrappedTemplatedEmail
{
    private $twig;
    private $message;
    public function __construct(Environment $twig, TemplatedEmail $message)
    {
        $this->twig = $twig;
        $this->message = $message;
    }
    public function toName(): string
    {
        return $this->message->getTo()[0]->getName();
    }
    public function image(string $image, string $contentType = null): string
    {
        $file = $this->twig->getLoader()->getSourceContext($image);
        if ($path = $file->getPath()) {
            $this->message->embedFromPath($path, $image, $contentType);
        } else {
            $this->message->embed($file->getCode(), $image, $contentType);
        }
        return 'cid:'.$image;
    }
    public function attach(string $file, string $name = null, string $contentType = null): void
    {
        $file = $this->twig->getLoader()->getSourceContext($file);
        if ($path = $file->getPath()) {
            $this->message->attachFromPath($path, $name, $contentType);
        } else {
            $this->message->attach($file->getCode(), $name, $contentType);
        }
    }
    /**
     * @return $this
     */
    public function setSubject(string $subject): self
    {
        $this->message->subject($subject);
        return $this;
    }
    public function getSubject(): ?string
    {
        return $this->message->getSubject();
    }
    /**
     * @return $this
     */
    public function setReturnPath(string $address): self
    {
        $this->message->returnPath($address);
        return $this;
    }
    public function getReturnPath(): string
    {
        return $this->message->getReturnPath();
    }
    /**
     * @return $this
     */
    public function addFrom(string $address, string $name = ''): self
    {
        $this->message->addFrom(new Address($address, $name));
        return $this;
    }
    /**
     * @return Address[]
     */
    public function getFrom(): array
    {
        return $this->message->getFrom();
    }
    /**
     * @return $this
     */
    public function addReplyTo(string $address): self
    {
        $this->message->addReplyTo($address);
        return $this;
    }
    /**
     * @return Address[]
     */
    public function getReplyTo(): array
    {
        return $this->message->getReplyTo();
    }
    /**
     * @return $this
     */
    public function addTo(string $address, string $name = ''): self
    {
        $this->message->addTo(new Address($address, $name));
        return $this;
    }
    /**
     * @return Address[]
     */
    public function getTo(): array
    {
        return $this->message->getTo();
    }
    /**
     * @return $this
     */
    public function addCc(string $address, string $name = ''): self
    {
        $this->message->addCc(new Address($address, $name));
        return $this;
    }
    /**
     * @return Address[]
     */
    public function getCc(): array
    {
        return $this->message->getCc();
    }
    /**
     * @return $this
     */
    public function addBcc(string $address, string $name = ''): self
    {
        $this->message->addBcc(new Address($address, $name));
        return $this;
    }
    /**
     * @return Address[]
     */
    public function getBcc(): array
    {
        return $this->message->getBcc();
    }
    /**
     * @return $this
     */
    public function setPriority(int $priority): self
    {
        $this->message->setPriority($priority);
        return $this;
    }
    public function getPriority(): int
    {
        return $this->message->getPriority();
    }
}