summaryrefslogtreecommitdiff
path: root/vendor/symfony/mime/Header/IdentificationHeader.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-06-03 14:19:10 +0100
committerGreg Roach <fisharebest@webtrees.net>2019-06-03 14:19:10 +0100
commit69c8d4f5c90cef75da102f92e4e992d03a8f1cd8 (patch)
tree4f956848961891482b64ee2cd5c8d7290936e354 /vendor/symfony/mime/Header/IdentificationHeader.php
parent425f99bc29ab9e477e5407b5c86da5c85ba47461 (diff)
downloadwebtrees-69c8d4f5c90cef75da102f92e4e992d03a8f1cd8.tar.gz
webtrees-69c8d4f5c90cef75da102f92e4e992d03a8f1cd8.tar.bz2
webtrees-69c8d4f5c90cef75da102f92e4e992d03a8f1cd8.zip
:Update vendor dependencies
Diffstat (limited to 'vendor/symfony/mime/Header/IdentificationHeader.php')
-rw-r--r--vendor/symfony/mime/Header/IdentificationHeader.php115
1 files changed, 115 insertions, 0 deletions
diff --git a/vendor/symfony/mime/Header/IdentificationHeader.php b/vendor/symfony/mime/Header/IdentificationHeader.php
new file mode 100644
index 0000000000..0695b688da
--- /dev/null
+++ b/vendor/symfony/mime/Header/IdentificationHeader.php
@@ -0,0 +1,115 @@
+<?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\Component\Mime\Header;
+
+use Symfony\Component\Mime\Address;
+use Symfony\Component\Mime\Exception\RfcComplianceException;
+
+/**
+ * An ID MIME Header for something like Message-ID or Content-ID (one or more addresses).
+ *
+ * @author Chris Corbyn
+ *
+ * @experimental in 4.3
+ */
+final class IdentificationHeader extends AbstractHeader
+{
+ private $ids = [];
+ private $idsAsAddresses = [];
+
+ /**
+ * @param string|array $ids
+ */
+ public function __construct(string $name, $ids)
+ {
+ parent::__construct($name);
+
+ $this->setId($ids);
+ }
+
+ /**
+ * @param string|array $body a string ID or an array of IDs
+ *
+ * @throws RfcComplianceException
+ */
+ public function setBody($body)
+ {
+ $this->setId($body);
+ }
+
+ /**
+ * @return array
+ */
+ public function getBody()
+ {
+ return $this->getIds();
+ }
+
+ /**
+ * Set the ID used in the value of this header.
+ *
+ * @param string|array $id
+ *
+ * @throws RfcComplianceException
+ */
+ public function setId($id)
+ {
+ $this->setIds(\is_array($id) ? $id : [$id]);
+ }
+
+ /**
+ * Get the ID used in the value of this Header.
+ *
+ * If multiple IDs are set only the first is returned.
+ */
+ public function getId(): ?string
+ {
+ return $this->ids[0] ?? null;
+ }
+
+ /**
+ * Set a collection of IDs to use in the value of this Header.
+ *
+ * @param string[] $ids
+ *
+ * @throws RfcComplianceException
+ */
+ public function setIds(array $ids)
+ {
+ $this->ids = [];
+ $this->idsAsAddresses = [];
+ foreach ($ids as $id) {
+ $this->idsAsAddresses[] = new Address($id);
+ $this->ids[] = $id;
+ }
+ }
+
+ /**
+ * Get the list of IDs used in this Header.
+ *
+ * @return string[]
+ */
+ public function getIds(): array
+ {
+ return $this->ids;
+ }
+
+ public function getBodyAsString(): string
+ {
+ $addrs = [];
+ foreach ($this->idsAsAddresses as $address) {
+ $addrs[] = '<'.$address->toString().'>';
+ }
+
+ return implode(' ', $addrs);
+ }
+}