Open Journal Systems  3.3.0
MailboxHeader.php
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
13 
16 
22 final class MailboxHeader extends AbstractHeader
23 {
24  private $address;
25 
26  public function __construct(string $name, Address $address)
27  {
28  parent::__construct($name);
29 
30  $this->setAddress($address);
31  }
32 
38  public function setBody($body)
39  {
40  $this->setAddress($body);
41  }
42 
46  public function getBody(): Address
47  {
48  return $this->getAddress();
49  }
50 
54  public function setAddress(Address $address)
55  {
56  $this->address = $address;
57  }
58 
59  public function getAddress(): Address
60  {
61  return $this->address;
62  }
63 
64  public function getBodyAsString(): string
65  {
66  $str = $this->address->getEncodedAddress();
67  if ($name = $this->address->getName()) {
68  $str = $this->createPhrase($this, $name, $this->getCharset(), true).' <'.$str.'>';
69  }
70 
71  return $str;
72  }
73 
81  protected function tokenNeedsEncoding(string $token): bool
82  {
83  return preg_match('/[()<>\[\]:;@\,."]/', $token) || parent::tokenNeedsEncoding($token);
84  }
85 }
Symfony\Component\Mime\Header\MailboxHeader\tokenNeedsEncoding
tokenNeedsEncoding(string $token)
Definition: MailboxHeader.php:81
Symfony\Component\Mime\Header\MailboxHeader\getBodyAsString
getBodyAsString()
Definition: MailboxHeader.php:64
Symfony\Component\Mime\Header\MailboxHeader\setBody
setBody($body)
Definition: MailboxHeader.php:38
Symfony\Component\Mime\Header\MailboxHeader\setAddress
setAddress(Address $address)
Definition: MailboxHeader.php:54
Symfony\Component\Mime\Address
Definition: Address.php:24
Symfony\Component\Mime\Exception\RfcComplianceException
Definition: RfcComplianceException.php:17
Symfony\Component\Mime\Header
Definition: AbstractHeader.php:12
Symfony\Component\Mime\Header\MailboxHeader\getAddress
getAddress()
Definition: MailboxHeader.php:59
Symfony\Component\Mime\Header\MailboxHeader\getBody
getBody()
Definition: MailboxHeader.php:46
Symfony\Component\Mime\Header\MailboxHeader\__construct
__construct(string $name, Address $address)
Definition: MailboxHeader.php:26
Symfony\Component\Mime\Header\MailboxHeader
Definition: MailboxHeader.php:22
Symfony\Component\Mime\Header\AbstractHeader\getCharset
getCharset()
Definition: AbstractHeader.php:42
Symfony\Component\Mime\Header\AbstractHeader
Definition: AbstractHeader.php:21
Symfony\Component\Mime\Header\AbstractHeader\createPhrase
createPhrase(HeaderInterface $header, string $string, string $charset, bool $shorten=false)
Definition: AbstractHeader.php:88