1<?php
2
3namespace Sabre\CalDAV\Xml\Property;
4
5use Sabre\Xml\Writer;
6use Sabre\Xml\XmlSerializable;
7
8/**
9 * email-address-set property
10 *
11 * This property represents the email-address-set property in the
12 * http://calendarserver.org/ns/ namespace.
13 *
14 * It's a list of email addresses associated with a user.
15 *
16 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
17 * @author Evert Pot (http://evertpot.com/)
18 * @license http://sabre.io/license/ Modified BSD License
19 */
20class EmailAddressSet implements XmlSerializable {
21
22    /**
23     * emails
24     *
25     * @var array
26     */
27    private $emails;
28
29    /**
30     * __construct
31     *
32     * @param array $emails
33     */
34    function __construct(array $emails) {
35
36        $this->emails = $emails;
37
38    }
39
40    /**
41     * Returns the email addresses
42     *
43     * @return array
44     */
45    function getValue() {
46
47        return $this->emails;
48
49    }
50
51    /**
52     * The xmlSerialize method is called during xml writing.
53     *
54     * Use the $writer argument to write its own xml serialization.
55     *
56     * An important note: do _not_ create a parent element. Any element
57     * implementing XmlSerializable should only ever write what's considered
58     * its 'inner xml'.
59     *
60     * The parent of the current element is responsible for writing a
61     * containing element.
62     *
63     * This allows serializers to be re-used for different element names.
64     *
65     * If you are opening new elements, you must also close them again.
66     *
67     * @param Writer $writer
68     * @return void
69     */
70    function xmlSerialize(Writer $writer) {
71
72        foreach ($this->emails as $email) {
73
74            $writer->writeElement('{http://calendarserver.org/ns/}email-address', $email);
75
76        }
77
78    }
79
80}
81