Completed
Branch develop (37f7b7)
by
unknown
24:41
created
htdocs/includes/sabre/sabre/vobject/lib/Recur/RDateIterator.php 1 patch
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -21,155 +21,155 @@
 block discarded – undo
21 21
  */
22 22
 class RDateIterator implements Iterator
23 23
 {
24
-    /**
25
-     * Creates the Iterator.
26
-     *
27
-     * @param string|array $rrule
28
-     */
29
-    public function __construct($rrule, DateTimeInterface $start)
30
-    {
31
-        $this->startDate = $start;
32
-        $this->parseRDate($rrule);
33
-        $this->currentDate = clone $this->startDate;
34
-    }
35
-
36
-    /* Implementation of the Iterator interface {{{ */
37
-
38
-    #[\ReturnTypeWillChange]
39
-    public function current()
40
-    {
41
-        if (!$this->valid()) {
42
-            return;
43
-        }
44
-
45
-        return clone $this->currentDate;
46
-    }
47
-
48
-    /**
49
-     * Returns the current item number.
50
-     *
51
-     * @return int
52
-     */
53
-    #[\ReturnTypeWillChange]
54
-    public function key()
55
-    {
56
-        return $this->counter;
57
-    }
58
-
59
-    /**
60
-     * Returns whether the current item is a valid item for the recurrence
61
-     * iterator.
62
-     *
63
-     * @return bool
64
-     */
65
-    #[\ReturnTypeWillChange]
66
-    public function valid()
67
-    {
68
-        return $this->counter <= count($this->dates);
69
-    }
70
-
71
-    /**
72
-     * Resets the iterator.
73
-     *
74
-     * @return void
75
-     */
76
-    #[\ReturnTypeWillChange]
77
-    public function rewind()
78
-    {
79
-        $this->currentDate = clone $this->startDate;
80
-        $this->counter = 0;
81
-    }
82
-
83
-    /**
84
-     * Goes on to the next iteration.
85
-     *
86
-     * @return void
87
-     */
88
-    #[\ReturnTypeWillChange]
89
-    public function next()
90
-    {
91
-        ++$this->counter;
92
-        if (!$this->valid()) {
93
-            return;
94
-        }
95
-
96
-        $this->currentDate =
97
-            DateTimeParser::parse(
98
-                $this->dates[$this->counter - 1],
99
-                $this->startDate->getTimezone()
100
-            );
101
-    }
102
-
103
-    /* End of Iterator implementation }}} */
104
-
105
-    /**
106
-     * Returns true if this recurring event never ends.
107
-     *
108
-     * @return bool
109
-     */
110
-    public function isInfinite()
111
-    {
112
-        return false;
113
-    }
114
-
115
-    /**
116
-     * This method allows you to quickly go to the next occurrence after the
117
-     * specified date.
118
-     */
119
-    public function fastForward(DateTimeInterface $dt)
120
-    {
121
-        while ($this->valid() && $this->currentDate < $dt) {
122
-            $this->next();
123
-        }
124
-    }
125
-
126
-    /**
127
-     * The reference start date/time for the rrule.
128
-     *
129
-     * All calculations are based on this initial date.
130
-     *
131
-     * @var DateTimeInterface
132
-     */
133
-    protected $startDate;
134
-
135
-    /**
136
-     * The date of the current iteration. You can get this by calling
137
-     * ->current().
138
-     *
139
-     * @var DateTimeInterface
140
-     */
141
-    protected $currentDate;
142
-
143
-    /**
144
-     * The current item in the list.
145
-     *
146
-     * You can get this number with the key() method.
147
-     *
148
-     * @var int
149
-     */
150
-    protected $counter = 0;
151
-
152
-    /* }}} */
153
-
154
-    /**
155
-     * This method receives a string from an RRULE property, and populates this
156
-     * class with all the values.
157
-     *
158
-     * @param string|array $rrule
159
-     */
160
-    protected function parseRDate($rdate)
161
-    {
162
-        if (is_string($rdate)) {
163
-            $rdate = explode(',', $rdate);
164
-        }
165
-
166
-        $this->dates = $rdate;
167
-    }
168
-
169
-    /**
170
-     * Array with the RRULE dates.
171
-     *
172
-     * @var array
173
-     */
174
-    protected $dates = [];
24
+	/**
25
+	 * Creates the Iterator.
26
+	 *
27
+	 * @param string|array $rrule
28
+	 */
29
+	public function __construct($rrule, DateTimeInterface $start)
30
+	{
31
+		$this->startDate = $start;
32
+		$this->parseRDate($rrule);
33
+		$this->currentDate = clone $this->startDate;
34
+	}
35
+
36
+	/* Implementation of the Iterator interface {{{ */
37
+
38
+	#[\ReturnTypeWillChange]
39
+	public function current()
40
+	{
41
+		if (!$this->valid()) {
42
+			return;
43
+		}
44
+
45
+		return clone $this->currentDate;
46
+	}
47
+
48
+	/**
49
+	 * Returns the current item number.
50
+	 *
51
+	 * @return int
52
+	 */
53
+	#[\ReturnTypeWillChange]
54
+	public function key()
55
+	{
56
+		return $this->counter;
57
+	}
58
+
59
+	/**
60
+	 * Returns whether the current item is a valid item for the recurrence
61
+	 * iterator.
62
+	 *
63
+	 * @return bool
64
+	 */
65
+	#[\ReturnTypeWillChange]
66
+	public function valid()
67
+	{
68
+		return $this->counter <= count($this->dates);
69
+	}
70
+
71
+	/**
72
+	 * Resets the iterator.
73
+	 *
74
+	 * @return void
75
+	 */
76
+	#[\ReturnTypeWillChange]
77
+	public function rewind()
78
+	{
79
+		$this->currentDate = clone $this->startDate;
80
+		$this->counter = 0;
81
+	}
82
+
83
+	/**
84
+	 * Goes on to the next iteration.
85
+	 *
86
+	 * @return void
87
+	 */
88
+	#[\ReturnTypeWillChange]
89
+	public function next()
90
+	{
91
+		++$this->counter;
92
+		if (!$this->valid()) {
93
+			return;
94
+		}
95
+
96
+		$this->currentDate =
97
+			DateTimeParser::parse(
98
+				$this->dates[$this->counter - 1],
99
+				$this->startDate->getTimezone()
100
+			);
101
+	}
102
+
103
+	/* End of Iterator implementation }}} */
104
+
105
+	/**
106
+	 * Returns true if this recurring event never ends.
107
+	 *
108
+	 * @return bool
109
+	 */
110
+	public function isInfinite()
111
+	{
112
+		return false;
113
+	}
114
+
115
+	/**
116
+	 * This method allows you to quickly go to the next occurrence after the
117
+	 * specified date.
118
+	 */
119
+	public function fastForward(DateTimeInterface $dt)
120
+	{
121
+		while ($this->valid() && $this->currentDate < $dt) {
122
+			$this->next();
123
+		}
124
+	}
125
+
126
+	/**
127
+	 * The reference start date/time for the rrule.
128
+	 *
129
+	 * All calculations are based on this initial date.
130
+	 *
131
+	 * @var DateTimeInterface
132
+	 */
133
+	protected $startDate;
134
+
135
+	/**
136
+	 * The date of the current iteration. You can get this by calling
137
+	 * ->current().
138
+	 *
139
+	 * @var DateTimeInterface
140
+	 */
141
+	protected $currentDate;
142
+
143
+	/**
144
+	 * The current item in the list.
145
+	 *
146
+	 * You can get this number with the key() method.
147
+	 *
148
+	 * @var int
149
+	 */
150
+	protected $counter = 0;
151
+
152
+	/* }}} */
153
+
154
+	/**
155
+	 * This method receives a string from an RRULE property, and populates this
156
+	 * class with all the values.
157
+	 *
158
+	 * @param string|array $rrule
159
+	 */
160
+	protected function parseRDate($rdate)
161
+	{
162
+		if (is_string($rdate)) {
163
+			$rdate = explode(',', $rdate);
164
+		}
165
+
166
+		$this->dates = $rdate;
167
+	}
168
+
169
+	/**
170
+	 * Array with the RRULE dates.
171
+	 *
172
+	 * @var array
173
+	 */
174
+	protected $dates = [];
175 175
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Property/Unknown.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -14,28 +14,28 @@
 block discarded – undo
14 14
  */
15 15
 class Unknown extends Text
16 16
 {
17
-    /**
18
-     * Returns the value, in the format it should be encoded for json.
19
-     *
20
-     * This method must always return an array.
21
-     *
22
-     * @return array
23
-     */
24
-    public function getJsonValue()
25
-    {
26
-        return [$this->getRawMimeDirValue()];
27
-    }
17
+	/**
18
+	 * Returns the value, in the format it should be encoded for json.
19
+	 *
20
+	 * This method must always return an array.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function getJsonValue()
25
+	{
26
+		return [$this->getRawMimeDirValue()];
27
+	}
28 28
 
29
-    /**
30
-     * Returns the type of value.
31
-     *
32
-     * This corresponds to the VALUE= parameter. Every property also has a
33
-     * 'default' valueType.
34
-     *
35
-     * @return string
36
-     */
37
-    public function getValueType()
38
-    {
39
-        return 'UNKNOWN';
40
-    }
29
+	/**
30
+	 * Returns the type of value.
31
+	 *
32
+	 * This corresponds to the VALUE= parameter. Every property also has a
33
+	 * 'default' valueType.
34
+	 *
35
+	 * @return string
36
+	 */
37
+	public function getValueType()
38
+	{
39
+		return 'UNKNOWN';
40
+	}
41 41
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Property/Binary.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -20,90 +20,90 @@
 block discarded – undo
20 20
  */
21 21
 class Binary extends Property
22 22
 {
23
-    /**
24
-     * In case this is a multi-value property. This string will be used as a
25
-     * delimiter.
26
-     *
27
-     * @var string
28
-     */
29
-    public $delimiter = '';
23
+	/**
24
+	 * In case this is a multi-value property. This string will be used as a
25
+	 * delimiter.
26
+	 *
27
+	 * @var string
28
+	 */
29
+	public $delimiter = '';
30 30
 
31
-    /**
32
-     * Updates the current value.
33
-     *
34
-     * This may be either a single, or multiple strings in an array.
35
-     *
36
-     * @param string|array $value
37
-     */
38
-    public function setValue($value)
39
-    {
40
-        if (is_array($value)) {
41
-            if (1 === count($value)) {
42
-                $this->value = $value[0];
43
-            } else {
44
-                throw new \InvalidArgumentException('The argument must either be a string or an array with only one child');
45
-            }
46
-        } else {
47
-            $this->value = $value;
48
-        }
49
-    }
31
+	/**
32
+	 * Updates the current value.
33
+	 *
34
+	 * This may be either a single, or multiple strings in an array.
35
+	 *
36
+	 * @param string|array $value
37
+	 */
38
+	public function setValue($value)
39
+	{
40
+		if (is_array($value)) {
41
+			if (1 === count($value)) {
42
+				$this->value = $value[0];
43
+			} else {
44
+				throw new \InvalidArgumentException('The argument must either be a string or an array with only one child');
45
+			}
46
+		} else {
47
+			$this->value = $value;
48
+		}
49
+	}
50 50
 
51
-    /**
52
-     * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
53
-     *
54
-     * This has been 'unfolded', so only 1 line will be passed. Unescaping is
55
-     * not yet done, but parameters are not included.
56
-     *
57
-     * @param string $val
58
-     */
59
-    public function setRawMimeDirValue($val)
60
-    {
61
-        $this->value = base64_decode($val);
62
-    }
51
+	/**
52
+	 * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
53
+	 *
54
+	 * This has been 'unfolded', so only 1 line will be passed. Unescaping is
55
+	 * not yet done, but parameters are not included.
56
+	 *
57
+	 * @param string $val
58
+	 */
59
+	public function setRawMimeDirValue($val)
60
+	{
61
+		$this->value = base64_decode($val);
62
+	}
63 63
 
64
-    /**
65
-     * Returns a raw mime-dir representation of the value.
66
-     *
67
-     * @return string
68
-     */
69
-    public function getRawMimeDirValue()
70
-    {
71
-        return base64_encode($this->value);
72
-    }
64
+	/**
65
+	 * Returns a raw mime-dir representation of the value.
66
+	 *
67
+	 * @return string
68
+	 */
69
+	public function getRawMimeDirValue()
70
+	{
71
+		return base64_encode($this->value);
72
+	}
73 73
 
74
-    /**
75
-     * Returns the type of value.
76
-     *
77
-     * This corresponds to the VALUE= parameter. Every property also has a
78
-     * 'default' valueType.
79
-     *
80
-     * @return string
81
-     */
82
-    public function getValueType()
83
-    {
84
-        return 'BINARY';
85
-    }
74
+	/**
75
+	 * Returns the type of value.
76
+	 *
77
+	 * This corresponds to the VALUE= parameter. Every property also has a
78
+	 * 'default' valueType.
79
+	 *
80
+	 * @return string
81
+	 */
82
+	public function getValueType()
83
+	{
84
+		return 'BINARY';
85
+	}
86 86
 
87
-    /**
88
-     * Returns the value, in the format it should be encoded for json.
89
-     *
90
-     * This method must always return an array.
91
-     *
92
-     * @return array
93
-     */
94
-    public function getJsonValue()
95
-    {
96
-        return [base64_encode($this->getValue())];
97
-    }
87
+	/**
88
+	 * Returns the value, in the format it should be encoded for json.
89
+	 *
90
+	 * This method must always return an array.
91
+	 *
92
+	 * @return array
93
+	 */
94
+	public function getJsonValue()
95
+	{
96
+		return [base64_encode($this->getValue())];
97
+	}
98 98
 
99
-    /**
100
-     * Sets the json value, as it would appear in a jCard or jCal object.
101
-     *
102
-     * The value must always be an array.
103
-     */
104
-    public function setJsonValue(array $value)
105
-    {
106
-        $value = array_map('base64_decode', $value);
107
-        parent::setJsonValue($value);
108
-    }
99
+	/**
100
+	 * Sets the json value, as it would appear in a jCard or jCal object.
101
+	 *
102
+	 * The value must always be an array.
103
+	 */
104
+	public function setJsonValue(array $value)
105
+	{
106
+		$value = array_map('base64_decode', $value);
107
+		parent::setJsonValue($value);
108
+	}
109 109
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Property/IntegerValue.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -16,61 +16,61 @@
 block discarded – undo
16 16
  */
17 17
 class IntegerValue extends Property
18 18
 {
19
-    /**
20
-     * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
21
-     *
22
-     * This has been 'unfolded', so only 1 line will be passed. Unescaping is
23
-     * not yet done, but parameters are not included.
24
-     *
25
-     * @param string $val
26
-     */
27
-    public function setRawMimeDirValue($val)
28
-    {
29
-        $this->setValue((int) $val);
30
-    }
19
+	/**
20
+	 * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
21
+	 *
22
+	 * This has been 'unfolded', so only 1 line will be passed. Unescaping is
23
+	 * not yet done, but parameters are not included.
24
+	 *
25
+	 * @param string $val
26
+	 */
27
+	public function setRawMimeDirValue($val)
28
+	{
29
+		$this->setValue((int) $val);
30
+	}
31 31
 
32
-    /**
33
-     * Returns a raw mime-dir representation of the value.
34
-     *
35
-     * @return string
36
-     */
37
-    public function getRawMimeDirValue()
38
-    {
39
-        return $this->value;
40
-    }
32
+	/**
33
+	 * Returns a raw mime-dir representation of the value.
34
+	 *
35
+	 * @return string
36
+	 */
37
+	public function getRawMimeDirValue()
38
+	{
39
+		return $this->value;
40
+	}
41 41
 
42
-    /**
43
-     * Returns the type of value.
44
-     *
45
-     * This corresponds to the VALUE= parameter. Every property also has a
46
-     * 'default' valueType.
47
-     *
48
-     * @return string
49
-     */
50
-    public function getValueType()
51
-    {
52
-        return 'INTEGER';
53
-    }
42
+	/**
43
+	 * Returns the type of value.
44
+	 *
45
+	 * This corresponds to the VALUE= parameter. Every property also has a
46
+	 * 'default' valueType.
47
+	 *
48
+	 * @return string
49
+	 */
50
+	public function getValueType()
51
+	{
52
+		return 'INTEGER';
53
+	}
54 54
 
55
-    /**
56
-     * Returns the value, in the format it should be encoded for json.
57
-     *
58
-     * This method must always return an array.
59
-     *
60
-     * @return array
61
-     */
62
-    public function getJsonValue()
63
-    {
64
-        return [(int) $this->getValue()];
65
-    }
55
+	/**
56
+	 * Returns the value, in the format it should be encoded for json.
57
+	 *
58
+	 * This method must always return an array.
59
+	 *
60
+	 * @return array
61
+	 */
62
+	public function getJsonValue()
63
+	{
64
+		return [(int) $this->getValue()];
65
+	}
66 66
 
67
-    /**
68
-     * Hydrate data from a XML subtree, as it would appear in a xCard or xCal
69
-     * object.
70
-     */
71
-    public function setXmlValue(array $value)
72
-    {
73
-        $value = array_map('intval', $value);
74
-        parent::setXmlValue($value);
75
-    }
67
+	/**
68
+	 * Hydrate data from a XML subtree, as it would appear in a xCard or xCal
69
+	 * object.
70
+	 */
71
+	public function setXmlValue(array $value)
72
+	{
73
+		$value = array_map('intval', $value);
74
+		parent::setXmlValue($value);
75
+	}
76 76
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Property/Text.php 2 patches
Indentation   +366 added lines, -366 removed lines patch added patch discarded remove patch
@@ -19,374 +19,374 @@
 block discarded – undo
19 19
  */
20 20
 class Text extends Property
21 21
 {
22
-    /**
23
-     * In case this is a multi-value property. This string will be used as a
24
-     * delimiter.
25
-     *
26
-     * @var string
27
-     */
28
-    public $delimiter = ',';
29
-
30
-    /**
31
-     * List of properties that are considered 'structured'.
32
-     *
33
-     * @var array
34
-     */
35
-    protected $structuredValues = [
36
-        // vCard
37
-        'N',
38
-        'ADR',
39
-        'ORG',
40
-        'GENDER',
41
-        'CLIENTPIDMAP',
42
-
43
-        // iCalendar
44
-        'REQUEST-STATUS',
45
-    ];
46
-
47
-    /**
48
-     * Some text components have a minimum number of components.
49
-     *
50
-     * N must for instance be represented as 5 components, separated by ;, even
51
-     * if the last few components are unused.
52
-     *
53
-     * @var array
54
-     */
55
-    protected $minimumPropertyValues = [
56
-        'N' => 5,
57
-        'ADR' => 7,
58
-    ];
59
-
60
-    /**
61
-     * Creates the property.
62
-     *
63
-     * You can specify the parameters either in key=>value syntax, in which case
64
-     * parameters will automatically be created, or you can just pass a list of
65
-     * Parameter objects.
66
-     *
67
-     * @param Component         $root       The root document
68
-     * @param string            $name
69
-     * @param string|array|null $value
70
-     * @param array             $parameters List of parameters
71
-     * @param string            $group      The vcard property group
72
-     */
73
-    public function __construct(Component $root, $name, $value = null, array $parameters = [], $group = null)
74
-    {
75
-        // There's two types of multi-valued text properties:
76
-        // 1. multivalue properties.
77
-        // 2. structured value properties
78
-        //
79
-        // The former is always separated by a comma, the latter by semi-colon.
80
-        if (in_array($name, $this->structuredValues)) {
81
-            $this->delimiter = ';';
82
-        }
83
-
84
-        parent::__construct($root, $name, $value, $parameters, $group);
85
-    }
86
-
87
-    /**
88
-     * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
89
-     *
90
-     * This has been 'unfolded', so only 1 line will be passed. Unescaping is
91
-     * not yet done, but parameters are not included.
92
-     *
93
-     * @param string $val
94
-     */
95
-    public function setRawMimeDirValue($val)
96
-    {
97
-        $this->setValue(MimeDir::unescapeValue($val, $this->delimiter));
98
-    }
99
-
100
-    /**
101
-     * Sets the value as a quoted-printable encoded string.
102
-     *
103
-     * @param string $val
104
-     */
105
-    public function setQuotedPrintableValue($val)
106
-    {
107
-        $val = quoted_printable_decode($val);
108
-
109
-        // Quoted printable only appears in vCard 2.1, and the only character
110
-        // that may be escaped there is ;. So we are simply splitting on just
111
-        // that.
112
-        //
113
-        // We also don't have to unescape \\, so all we need to look for is a ;
114
-        // that's not preceded with a \.
115
-        $regex = '# (?<!\\\\) ; #x';
116
-        $matches = preg_split($regex, $val);
117
-        $this->setValue($matches);
118
-    }
119
-
120
-    /**
121
-     * Returns a raw mime-dir representation of the value.
122
-     *
123
-     * @return string
124
-     */
125
-    public function getRawMimeDirValue()
126
-    {
127
-        $val = $this->getParts();
128
-
129
-        if (isset($this->minimumPropertyValues[$this->name])) {
130
-            $val = array_pad($val, $this->minimumPropertyValues[$this->name], '');
131
-        }
132
-
133
-        foreach ($val as &$item) {
134
-            if (!is_array($item)) {
135
-                $item = [$item];
136
-            }
137
-
138
-            foreach ($item as &$subItem) {
139
-                if (!is_null($subItem)) {
140
-                    $subItem = strtr(
141
-                        $subItem,
142
-                        [
143
-                            '\\' => '\\\\',
144
-                            ';' => '\;',
145
-                            ',' => '\,',
146
-                            "\n" => '\n',
147
-                            "\r" => '',
148
-                        ]
149
-                    );
150
-                }
151
-            }
152
-            $item = implode(',', $item);
153
-        }
154
-
155
-        return implode($this->delimiter, $val);
156
-    }
157
-
158
-    /**
159
-     * Returns the value, in the format it should be encoded for json.
160
-     *
161
-     * This method must always return an array.
162
-     *
163
-     * @return array
164
-     */
165
-    public function getJsonValue()
166
-    {
167
-        // Structured text values should always be returned as a single
168
-        // array-item. Multi-value text should be returned as multiple items in
169
-        // the top-array.
170
-        if (in_array($this->name, $this->structuredValues)) {
171
-            return [$this->getParts()];
172
-        }
173
-
174
-        return $this->getParts();
175
-    }
176
-
177
-    /**
178
-     * Returns the type of value.
179
-     *
180
-     * This corresponds to the VALUE= parameter. Every property also has a
181
-     * 'default' valueType.
182
-     *
183
-     * @return string
184
-     */
185
-    public function getValueType()
186
-    {
187
-        return 'TEXT';
188
-    }
189
-
190
-    /**
191
-     * Turns the object back into a serialized blob.
192
-     *
193
-     * @return string
194
-     */
195
-    public function serialize()
196
-    {
197
-        // We need to kick in a special type of encoding, if it's a 2.1 vcard.
198
-        if (Document::VCARD21 !== $this->root->getDocumentType()) {
199
-            return parent::serialize();
200
-        }
201
-
202
-        $val = $this->getParts();
203
-
204
-        if (isset($this->minimumPropertyValues[$this->name])) {
205
-            $val = \array_pad($val, $this->minimumPropertyValues[$this->name], '');
206
-        }
207
-
208
-        // Imploding multiple parts into a single value, and splitting the
209
-        // values with ;.
210
-        if (\count($val) > 1) {
211
-            foreach ($val as $k => $v) {
212
-                $val[$k] = \str_replace(';', '\;', $v);
213
-            }
214
-            $val = \implode(';', $val);
215
-        } else {
216
-            $val = $val[0];
217
-        }
218
-
219
-        $str = $this->name;
220
-        if ($this->group) {
221
-            $str = $this->group.'.'.$this->name;
222
-        }
223
-        foreach ($this->parameters as $param) {
224
-            if ('QUOTED-PRINTABLE' === $param->getValue()) {
225
-                continue;
226
-            }
227
-            $str .= ';'.$param->serialize();
228
-        }
229
-
230
-        // If the resulting value contains a \n, we must encode it as
231
-        // quoted-printable.
232
-        if (false !== \strpos($val, "\n")) {
233
-            $str .= ';ENCODING=QUOTED-PRINTABLE:';
234
-            $lastLine = $str;
235
-            $out = null;
236
-
237
-            // The PHP built-in quoted-printable-encode does not correctly
238
-            // encode newlines for us. Specifically, the \r\n sequence must in
239
-            // vcards be encoded as =0D=OA and we must insert soft-newlines
240
-            // every 75 bytes.
241
-            for ($ii = 0; $ii < \strlen($val); ++$ii) {
242
-                $ord = \ord($val[$ii]);
243
-                // These characters are encoded as themselves.
244
-                if ($ord >= 32 && $ord <= 126) {
245
-                    $lastLine .= $val[$ii];
246
-                } else {
247
-                    $lastLine .= '='.\strtoupper(\bin2hex($val[$ii]));
248
-                }
249
-                if (\strlen($lastLine) >= 75) {
250
-                    // Soft line break
251
-                    $out .= $lastLine."=\r\n ";
252
-                    $lastLine = null;
253
-                }
254
-            }
255
-            if (!\is_null($lastLine)) {
256
-                $out .= $lastLine."\r\n";
257
-            }
258
-
259
-            return $out;
260
-        } else {
261
-            $str .= ':'.$val;
262
-
263
-            $str = \preg_replace(
264
-                '/(
22
+	/**
23
+	 * In case this is a multi-value property. This string will be used as a
24
+	 * delimiter.
25
+	 *
26
+	 * @var string
27
+	 */
28
+	public $delimiter = ',';
29
+
30
+	/**
31
+	 * List of properties that are considered 'structured'.
32
+	 *
33
+	 * @var array
34
+	 */
35
+	protected $structuredValues = [
36
+		// vCard
37
+		'N',
38
+		'ADR',
39
+		'ORG',
40
+		'GENDER',
41
+		'CLIENTPIDMAP',
42
+
43
+		// iCalendar
44
+		'REQUEST-STATUS',
45
+	];
46
+
47
+	/**
48
+	 * Some text components have a minimum number of components.
49
+	 *
50
+	 * N must for instance be represented as 5 components, separated by ;, even
51
+	 * if the last few components are unused.
52
+	 *
53
+	 * @var array
54
+	 */
55
+	protected $minimumPropertyValues = [
56
+		'N' => 5,
57
+		'ADR' => 7,
58
+	];
59
+
60
+	/**
61
+	 * Creates the property.
62
+	 *
63
+	 * You can specify the parameters either in key=>value syntax, in which case
64
+	 * parameters will automatically be created, or you can just pass a list of
65
+	 * Parameter objects.
66
+	 *
67
+	 * @param Component         $root       The root document
68
+	 * @param string            $name
69
+	 * @param string|array|null $value
70
+	 * @param array             $parameters List of parameters
71
+	 * @param string            $group      The vcard property group
72
+	 */
73
+	public function __construct(Component $root, $name, $value = null, array $parameters = [], $group = null)
74
+	{
75
+		// There's two types of multi-valued text properties:
76
+		// 1. multivalue properties.
77
+		// 2. structured value properties
78
+		//
79
+		// The former is always separated by a comma, the latter by semi-colon.
80
+		if (in_array($name, $this->structuredValues)) {
81
+			$this->delimiter = ';';
82
+		}
83
+
84
+		parent::__construct($root, $name, $value, $parameters, $group);
85
+	}
86
+
87
+	/**
88
+	 * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
89
+	 *
90
+	 * This has been 'unfolded', so only 1 line will be passed. Unescaping is
91
+	 * not yet done, but parameters are not included.
92
+	 *
93
+	 * @param string $val
94
+	 */
95
+	public function setRawMimeDirValue($val)
96
+	{
97
+		$this->setValue(MimeDir::unescapeValue($val, $this->delimiter));
98
+	}
99
+
100
+	/**
101
+	 * Sets the value as a quoted-printable encoded string.
102
+	 *
103
+	 * @param string $val
104
+	 */
105
+	public function setQuotedPrintableValue($val)
106
+	{
107
+		$val = quoted_printable_decode($val);
108
+
109
+		// Quoted printable only appears in vCard 2.1, and the only character
110
+		// that may be escaped there is ;. So we are simply splitting on just
111
+		// that.
112
+		//
113
+		// We also don't have to unescape \\, so all we need to look for is a ;
114
+		// that's not preceded with a \.
115
+		$regex = '# (?<!\\\\) ; #x';
116
+		$matches = preg_split($regex, $val);
117
+		$this->setValue($matches);
118
+	}
119
+
120
+	/**
121
+	 * Returns a raw mime-dir representation of the value.
122
+	 *
123
+	 * @return string
124
+	 */
125
+	public function getRawMimeDirValue()
126
+	{
127
+		$val = $this->getParts();
128
+
129
+		if (isset($this->minimumPropertyValues[$this->name])) {
130
+			$val = array_pad($val, $this->minimumPropertyValues[$this->name], '');
131
+		}
132
+
133
+		foreach ($val as &$item) {
134
+			if (!is_array($item)) {
135
+				$item = [$item];
136
+			}
137
+
138
+			foreach ($item as &$subItem) {
139
+				if (!is_null($subItem)) {
140
+					$subItem = strtr(
141
+						$subItem,
142
+						[
143
+							'\\' => '\\\\',
144
+							';' => '\;',
145
+							',' => '\,',
146
+							"\n" => '\n',
147
+							"\r" => '',
148
+						]
149
+					);
150
+				}
151
+			}
152
+			$item = implode(',', $item);
153
+		}
154
+
155
+		return implode($this->delimiter, $val);
156
+	}
157
+
158
+	/**
159
+	 * Returns the value, in the format it should be encoded for json.
160
+	 *
161
+	 * This method must always return an array.
162
+	 *
163
+	 * @return array
164
+	 */
165
+	public function getJsonValue()
166
+	{
167
+		// Structured text values should always be returned as a single
168
+		// array-item. Multi-value text should be returned as multiple items in
169
+		// the top-array.
170
+		if (in_array($this->name, $this->structuredValues)) {
171
+			return [$this->getParts()];
172
+		}
173
+
174
+		return $this->getParts();
175
+	}
176
+
177
+	/**
178
+	 * Returns the type of value.
179
+	 *
180
+	 * This corresponds to the VALUE= parameter. Every property also has a
181
+	 * 'default' valueType.
182
+	 *
183
+	 * @return string
184
+	 */
185
+	public function getValueType()
186
+	{
187
+		return 'TEXT';
188
+	}
189
+
190
+	/**
191
+	 * Turns the object back into a serialized blob.
192
+	 *
193
+	 * @return string
194
+	 */
195
+	public function serialize()
196
+	{
197
+		// We need to kick in a special type of encoding, if it's a 2.1 vcard.
198
+		if (Document::VCARD21 !== $this->root->getDocumentType()) {
199
+			return parent::serialize();
200
+		}
201
+
202
+		$val = $this->getParts();
203
+
204
+		if (isset($this->minimumPropertyValues[$this->name])) {
205
+			$val = \array_pad($val, $this->minimumPropertyValues[$this->name], '');
206
+		}
207
+
208
+		// Imploding multiple parts into a single value, and splitting the
209
+		// values with ;.
210
+		if (\count($val) > 1) {
211
+			foreach ($val as $k => $v) {
212
+				$val[$k] = \str_replace(';', '\;', $v);
213
+			}
214
+			$val = \implode(';', $val);
215
+		} else {
216
+			$val = $val[0];
217
+		}
218
+
219
+		$str = $this->name;
220
+		if ($this->group) {
221
+			$str = $this->group.'.'.$this->name;
222
+		}
223
+		foreach ($this->parameters as $param) {
224
+			if ('QUOTED-PRINTABLE' === $param->getValue()) {
225
+				continue;
226
+			}
227
+			$str .= ';'.$param->serialize();
228
+		}
229
+
230
+		// If the resulting value contains a \n, we must encode it as
231
+		// quoted-printable.
232
+		if (false !== \strpos($val, "\n")) {
233
+			$str .= ';ENCODING=QUOTED-PRINTABLE:';
234
+			$lastLine = $str;
235
+			$out = null;
236
+
237
+			// The PHP built-in quoted-printable-encode does not correctly
238
+			// encode newlines for us. Specifically, the \r\n sequence must in
239
+			// vcards be encoded as =0D=OA and we must insert soft-newlines
240
+			// every 75 bytes.
241
+			for ($ii = 0; $ii < \strlen($val); ++$ii) {
242
+				$ord = \ord($val[$ii]);
243
+				// These characters are encoded as themselves.
244
+				if ($ord >= 32 && $ord <= 126) {
245
+					$lastLine .= $val[$ii];
246
+				} else {
247
+					$lastLine .= '='.\strtoupper(\bin2hex($val[$ii]));
248
+				}
249
+				if (\strlen($lastLine) >= 75) {
250
+					// Soft line break
251
+					$out .= $lastLine."=\r\n ";
252
+					$lastLine = null;
253
+				}
254
+			}
255
+			if (!\is_null($lastLine)) {
256
+				$out .= $lastLine."\r\n";
257
+			}
258
+
259
+			return $out;
260
+		} else {
261
+			$str .= ':'.$val;
262
+
263
+			$str = \preg_replace(
264
+				'/(
265 265
                     (?:^.)?         # 1 additional byte in first line because of missing single space (see next line)
266 266
                     .{1,74}         # max 75 bytes per line (1 byte is used for a single space added after every CRLF)
267 267
                     (?![\x80-\xbf]) # prevent splitting multibyte characters
268 268
                 )/x',
269
-                "$1\r\n ",
270
-                $str
271
-            );
272
-
273
-            // remove single space after last CRLF
274
-            return \substr($str, 0, -1);
275
-        }
276
-    }
277
-
278
-    /**
279
-     * This method serializes only the value of a property. This is used to
280
-     * create xCard or xCal documents.
281
-     *
282
-     * @param Xml\Writer $writer XML writer
283
-     */
284
-    protected function xmlSerializeValue(Xml\Writer $writer)
285
-    {
286
-        $values = $this->getParts();
287
-
288
-        $map = function ($items) use ($values, $writer) {
289
-            foreach ($items as $i => $item) {
290
-                $writer->writeElement(
291
-                    $item,
292
-                    !empty($values[$i]) ? $values[$i] : null
293
-                );
294
-            }
295
-        };
296
-
297
-        switch ($this->name) {
298
-            // Special-casing the REQUEST-STATUS property.
299
-            //
300
-            // See:
301
-            // http://tools.ietf.org/html/rfc6321#section-3.4.1.3
302
-            case 'REQUEST-STATUS':
303
-                $writer->writeElement('code', $values[0]);
304
-                $writer->writeElement('description', $values[1]);
305
-
306
-                if (isset($values[2])) {
307
-                    $writer->writeElement('data', $values[2]);
308
-                }
309
-                break;
310
-
311
-            case 'N':
312
-                $map([
313
-                    'surname',
314
-                    'given',
315
-                    'additional',
316
-                    'prefix',
317
-                    'suffix',
318
-                ]);
319
-                break;
320
-
321
-            case 'GENDER':
322
-                $map([
323
-                    'sex',
324
-                    'text',
325
-                ]);
326
-                break;
327
-
328
-            case 'ADR':
329
-                $map([
330
-                    'pobox',
331
-                    'ext',
332
-                    'street',
333
-                    'locality',
334
-                    'region',
335
-                    'code',
336
-                    'country',
337
-                ]);
338
-                break;
339
-
340
-            case 'CLIENTPIDMAP':
341
-                $map([
342
-                    'sourceid',
343
-                    'uri',
344
-                ]);
345
-                break;
346
-
347
-            default:
348
-                parent::xmlSerializeValue($writer);
349
-        }
350
-    }
351
-
352
-    /**
353
-     * Validates the node for correctness.
354
-     *
355
-     * The following options are supported:
356
-     *   - Node::REPAIR - If something is broken, and automatic repair may
357
-     *                    be attempted.
358
-     *
359
-     * An array is returned with warnings.
360
-     *
361
-     * Every item in the array has the following properties:
362
-     *    * level - (number between 1 and 3 with severity information)
363
-     *    * message - (human readable message)
364
-     *    * node - (reference to the offending node)
365
-     *
366
-     * @param int $options
367
-     *
368
-     * @return array
369
-     */
370
-    public function validate($options = 0)
371
-    {
372
-        $warnings = parent::validate($options);
373
-
374
-        if (isset($this->minimumPropertyValues[$this->name])) {
375
-            $minimum = $this->minimumPropertyValues[$this->name];
376
-            $parts = $this->getParts();
377
-            if (count($parts) < $minimum) {
378
-                $warnings[] = [
379
-                    'level' => $options & self::REPAIR ? 1 : 3,
380
-                    'message' => 'The '.$this->name.' property must have at least '.$minimum.' values. It only has '.count($parts),
381
-                    'node' => $this,
382
-                ];
383
-                if ($options & self::REPAIR) {
384
-                    $parts = array_pad($parts, $minimum, '');
385
-                    $this->setParts($parts);
386
-                }
387
-            }
388
-        }
389
-
390
-        return $warnings;
391
-    }
269
+				"$1\r\n ",
270
+				$str
271
+			);
272
+
273
+			// remove single space after last CRLF
274
+			return \substr($str, 0, -1);
275
+		}
276
+	}
277
+
278
+	/**
279
+	 * This method serializes only the value of a property. This is used to
280
+	 * create xCard or xCal documents.
281
+	 *
282
+	 * @param Xml\Writer $writer XML writer
283
+	 */
284
+	protected function xmlSerializeValue(Xml\Writer $writer)
285
+	{
286
+		$values = $this->getParts();
287
+
288
+		$map = function ($items) use ($values, $writer) {
289
+			foreach ($items as $i => $item) {
290
+				$writer->writeElement(
291
+					$item,
292
+					!empty($values[$i]) ? $values[$i] : null
293
+				);
294
+			}
295
+		};
296
+
297
+		switch ($this->name) {
298
+			// Special-casing the REQUEST-STATUS property.
299
+			//
300
+			// See:
301
+			// http://tools.ietf.org/html/rfc6321#section-3.4.1.3
302
+			case 'REQUEST-STATUS':
303
+				$writer->writeElement('code', $values[0]);
304
+				$writer->writeElement('description', $values[1]);
305
+
306
+				if (isset($values[2])) {
307
+					$writer->writeElement('data', $values[2]);
308
+				}
309
+				break;
310
+
311
+			case 'N':
312
+				$map([
313
+					'surname',
314
+					'given',
315
+					'additional',
316
+					'prefix',
317
+					'suffix',
318
+				]);
319
+				break;
320
+
321
+			case 'GENDER':
322
+				$map([
323
+					'sex',
324
+					'text',
325
+				]);
326
+				break;
327
+
328
+			case 'ADR':
329
+				$map([
330
+					'pobox',
331
+					'ext',
332
+					'street',
333
+					'locality',
334
+					'region',
335
+					'code',
336
+					'country',
337
+				]);
338
+				break;
339
+
340
+			case 'CLIENTPIDMAP':
341
+				$map([
342
+					'sourceid',
343
+					'uri',
344
+				]);
345
+				break;
346
+
347
+			default:
348
+				parent::xmlSerializeValue($writer);
349
+		}
350
+	}
351
+
352
+	/**
353
+	 * Validates the node for correctness.
354
+	 *
355
+	 * The following options are supported:
356
+	 *   - Node::REPAIR - If something is broken, and automatic repair may
357
+	 *                    be attempted.
358
+	 *
359
+	 * An array is returned with warnings.
360
+	 *
361
+	 * Every item in the array has the following properties:
362
+	 *    * level - (number between 1 and 3 with severity information)
363
+	 *    * message - (human readable message)
364
+	 *    * node - (reference to the offending node)
365
+	 *
366
+	 * @param int $options
367
+	 *
368
+	 * @return array
369
+	 */
370
+	public function validate($options = 0)
371
+	{
372
+		$warnings = parent::validate($options);
373
+
374
+		if (isset($this->minimumPropertyValues[$this->name])) {
375
+			$minimum = $this->minimumPropertyValues[$this->name];
376
+			$parts = $this->getParts();
377
+			if (count($parts) < $minimum) {
378
+				$warnings[] = [
379
+					'level' => $options & self::REPAIR ? 1 : 3,
380
+					'message' => 'The '.$this->name.' property must have at least '.$minimum.' values. It only has '.count($parts),
381
+					'node' => $this,
382
+				];
383
+				if ($options & self::REPAIR) {
384
+					$parts = array_pad($parts, $minimum, '');
385
+					$this->setParts($parts);
386
+				}
387
+			}
388
+		}
389
+
390
+		return $warnings;
391
+	}
392 392
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -285,7 +285,7 @@
 block discarded – undo
285 285
     {
286 286
         $values = $this->getParts();
287 287
 
288
-        $map = function ($items) use ($values, $writer) {
288
+        $map = function($items) use ($values, $writer) {
289 289
             foreach ($items as $i => $item) {
290 290
                 $writer->writeElement(
291 291
                     $item,
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Property/Uri.php 1 patch
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -16,101 +16,101 @@
 block discarded – undo
16 16
  */
17 17
 class Uri extends Text
18 18
 {
19
-    /**
20
-     * In case this is a multi-value property. This string will be used as a
21
-     * delimiter.
22
-     *
23
-     * @var string
24
-     */
25
-    public $delimiter = '';
19
+	/**
20
+	 * In case this is a multi-value property. This string will be used as a
21
+	 * delimiter.
22
+	 *
23
+	 * @var string
24
+	 */
25
+	public $delimiter = '';
26 26
 
27
-    /**
28
-     * Returns the type of value.
29
-     *
30
-     * This corresponds to the VALUE= parameter. Every property also has a
31
-     * 'default' valueType.
32
-     *
33
-     * @return string
34
-     */
35
-    public function getValueType()
36
-    {
37
-        return 'URI';
38
-    }
27
+	/**
28
+	 * Returns the type of value.
29
+	 *
30
+	 * This corresponds to the VALUE= parameter. Every property also has a
31
+	 * 'default' valueType.
32
+	 *
33
+	 * @return string
34
+	 */
35
+	public function getValueType()
36
+	{
37
+		return 'URI';
38
+	}
39 39
 
40
-    /**
41
-     * Returns an iterable list of children.
42
-     *
43
-     * @return array
44
-     */
45
-    public function parameters()
46
-    {
47
-        $parameters = parent::parameters();
48
-        if (!isset($parameters['VALUE']) && in_array($this->name, ['URL', 'PHOTO'])) {
49
-            // If we are encoding a URI value, and this URI value has no
50
-            // VALUE=URI parameter, we add it anyway.
51
-            //
52
-            // This is not required by any spec, but both Apple iCal and Apple
53
-            // AddressBook (at least in version 10.8) will trip over this if
54
-            // this is not set, and so it improves compatibility.
55
-            //
56
-            // See Issue #227 and #235
57
-            $parameters['VALUE'] = new Parameter($this->root, 'VALUE', 'URI');
58
-        }
40
+	/**
41
+	 * Returns an iterable list of children.
42
+	 *
43
+	 * @return array
44
+	 */
45
+	public function parameters()
46
+	{
47
+		$parameters = parent::parameters();
48
+		if (!isset($parameters['VALUE']) && in_array($this->name, ['URL', 'PHOTO'])) {
49
+			// If we are encoding a URI value, and this URI value has no
50
+			// VALUE=URI parameter, we add it anyway.
51
+			//
52
+			// This is not required by any spec, but both Apple iCal and Apple
53
+			// AddressBook (at least in version 10.8) will trip over this if
54
+			// this is not set, and so it improves compatibility.
55
+			//
56
+			// See Issue #227 and #235
57
+			$parameters['VALUE'] = new Parameter($this->root, 'VALUE', 'URI');
58
+		}
59 59
 
60
-        return $parameters;
61
-    }
60
+		return $parameters;
61
+	}
62 62
 
63
-    /**
64
-     * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
65
-     *
66
-     * This has been 'unfolded', so only 1 line will be passed. Unescaping is
67
-     * not yet done, but parameters are not included.
68
-     *
69
-     * @param string $val
70
-     */
71
-    public function setRawMimeDirValue($val)
72
-    {
73
-        // Normally we don't need to do any type of unescaping for these
74
-        // properties, however.. we've noticed that Google Contacts
75
-        // specifically escapes the colon (:) with a backslash. While I have
76
-        // no clue why they thought that was a good idea, I'm unescaping it
77
-        // anyway.
78
-        //
79
-        // Good thing backslashes are not allowed in urls. Makes it easy to
80
-        // assume that a backslash is always intended as an escape character.
81
-        if ('URL' === $this->name) {
82
-            $regex = '#  (?: (\\\\ (?: \\\\ | : ) ) ) #x';
83
-            $matches = preg_split($regex, $val, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
84
-            $newVal = '';
85
-            foreach ($matches as $match) {
86
-                switch ($match) {
87
-                    case '\:':
88
-                        $newVal .= ':';
89
-                        break;
90
-                    default:
91
-                        $newVal .= $match;
92
-                        break;
93
-                }
94
-            }
95
-            $this->value = $newVal;
96
-        } else {
97
-            $this->value = strtr($val, ['\,' => ',']);
98
-        }
99
-    }
63
+	/**
64
+	 * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
65
+	 *
66
+	 * This has been 'unfolded', so only 1 line will be passed. Unescaping is
67
+	 * not yet done, but parameters are not included.
68
+	 *
69
+	 * @param string $val
70
+	 */
71
+	public function setRawMimeDirValue($val)
72
+	{
73
+		// Normally we don't need to do any type of unescaping for these
74
+		// properties, however.. we've noticed that Google Contacts
75
+		// specifically escapes the colon (:) with a backslash. While I have
76
+		// no clue why they thought that was a good idea, I'm unescaping it
77
+		// anyway.
78
+		//
79
+		// Good thing backslashes are not allowed in urls. Makes it easy to
80
+		// assume that a backslash is always intended as an escape character.
81
+		if ('URL' === $this->name) {
82
+			$regex = '#  (?: (\\\\ (?: \\\\ | : ) ) ) #x';
83
+			$matches = preg_split($regex, $val, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
84
+			$newVal = '';
85
+			foreach ($matches as $match) {
86
+				switch ($match) {
87
+					case '\:':
88
+						$newVal .= ':';
89
+						break;
90
+					default:
91
+						$newVal .= $match;
92
+						break;
93
+				}
94
+			}
95
+			$this->value = $newVal;
96
+		} else {
97
+			$this->value = strtr($val, ['\,' => ',']);
98
+		}
99
+	}
100 100
 
101
-    /**
102
-     * Returns a raw mime-dir representation of the value.
103
-     *
104
-     * @return string
105
-     */
106
-    public function getRawMimeDirValue()
107
-    {
108
-        if (is_array($this->value)) {
109
-            $value = $this->value[0];
110
-        } else {
111
-            $value = $this->value;
112
-        }
101
+	/**
102
+	 * Returns a raw mime-dir representation of the value.
103
+	 *
104
+	 * @return string
105
+	 */
106
+	public function getRawMimeDirValue()
107
+	{
108
+		if (is_array($this->value)) {
109
+			$value = $this->value[0];
110
+		} else {
111
+			$value = $this->value;
112
+		}
113 113
 
114
-        return strtr($value, [',' => '\,']);
115
-    }
114
+		return strtr($value, [',' => '\,']);
115
+	}
116 116
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Property/UtcOffset.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -13,58 +13,58 @@
 block discarded – undo
13 13
  */
14 14
 class UtcOffset extends Text
15 15
 {
16
-    /**
17
-     * In case this is a multi-value property. This string will be used as a
18
-     * delimiter.
19
-     *
20
-     * @var string
21
-     */
22
-    public $delimiter = '';
16
+	/**
17
+	 * In case this is a multi-value property. This string will be used as a
18
+	 * delimiter.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	public $delimiter = '';
23 23
 
24
-    /**
25
-     * Returns the type of value.
26
-     *
27
-     * This corresponds to the VALUE= parameter. Every property also has a
28
-     * 'default' valueType.
29
-     *
30
-     * @return string
31
-     */
32
-    public function getValueType()
33
-    {
34
-        return 'UTC-OFFSET';
35
-    }
24
+	/**
25
+	 * Returns the type of value.
26
+	 *
27
+	 * This corresponds to the VALUE= parameter. Every property also has a
28
+	 * 'default' valueType.
29
+	 *
30
+	 * @return string
31
+	 */
32
+	public function getValueType()
33
+	{
34
+		return 'UTC-OFFSET';
35
+	}
36 36
 
37
-    /**
38
-     * Sets the JSON value, as it would appear in a jCard or jCal object.
39
-     *
40
-     * The value must always be an array.
41
-     */
42
-    public function setJsonValue(array $value)
43
-    {
44
-        $value = array_map(
45
-            function ($value) {
46
-                return str_replace(':', '', $value);
47
-            },
48
-            $value
49
-        );
50
-        parent::setJsonValue($value);
51
-    }
37
+	/**
38
+	 * Sets the JSON value, as it would appear in a jCard or jCal object.
39
+	 *
40
+	 * The value must always be an array.
41
+	 */
42
+	public function setJsonValue(array $value)
43
+	{
44
+		$value = array_map(
45
+			function ($value) {
46
+				return str_replace(':', '', $value);
47
+			},
48
+			$value
49
+		);
50
+		parent::setJsonValue($value);
51
+	}
52 52
 
53
-    /**
54
-     * Returns the value, in the format it should be encoded for JSON.
55
-     *
56
-     * This method must always return an array.
57
-     *
58
-     * @return array
59
-     */
60
-    public function getJsonValue()
61
-    {
62
-        return array_map(
63
-            function ($value) {
64
-                return substr($value, 0, -2).':'.
65
-                       substr($value, -2);
66
-            },
67
-            parent::getJsonValue()
68
-        );
69
-    }
53
+	/**
54
+	 * Returns the value, in the format it should be encoded for JSON.
55
+	 *
56
+	 * This method must always return an array.
57
+	 *
58
+	 * @return array
59
+	 */
60
+	public function getJsonValue()
61
+	{
62
+		return array_map(
63
+			function ($value) {
64
+				return substr($value, 0, -2).':'.
65
+					   substr($value, -2);
66
+			},
67
+			parent::getJsonValue()
68
+		);
69
+	}
70 70
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     public function setJsonValue(array $value)
43 43
     {
44 44
         $value = array_map(
45
-            function ($value) {
45
+            function($value) {
46 46
                 return str_replace(':', '', $value);
47 47
             },
48 48
             $value
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     public function getJsonValue()
61 61
     {
62 62
         return array_map(
63
-            function ($value) {
63
+            function($value) {
64 64
                 return substr($value, 0, -2).':'.
65 65
                        substr($value, -2);
66 66
             },
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Property/ICalendar/Period.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -19,117 +19,117 @@
 block discarded – undo
19 19
  */
20 20
 class Period extends Property
21 21
 {
22
-    /**
23
-     * In case this is a multi-value property. This string will be used as a
24
-     * delimiter.
25
-     *
26
-     * @var string
27
-     */
28
-    public $delimiter = ',';
22
+	/**
23
+	 * In case this is a multi-value property. This string will be used as a
24
+	 * delimiter.
25
+	 *
26
+	 * @var string
27
+	 */
28
+	public $delimiter = ',';
29 29
 
30
-    /**
31
-     * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
32
-     *
33
-     * This has been 'unfolded', so only 1 line will be passed. Unescaping is
34
-     * not yet done, but parameters are not included.
35
-     *
36
-     * @param string $val
37
-     */
38
-    public function setRawMimeDirValue($val)
39
-    {
40
-        $this->setValue(explode($this->delimiter, $val));
41
-    }
30
+	/**
31
+	 * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
32
+	 *
33
+	 * This has been 'unfolded', so only 1 line will be passed. Unescaping is
34
+	 * not yet done, but parameters are not included.
35
+	 *
36
+	 * @param string $val
37
+	 */
38
+	public function setRawMimeDirValue($val)
39
+	{
40
+		$this->setValue(explode($this->delimiter, $val));
41
+	}
42 42
 
43
-    /**
44
-     * Returns a raw mime-dir representation of the value.
45
-     *
46
-     * @return string
47
-     */
48
-    public function getRawMimeDirValue()
49
-    {
50
-        return implode($this->delimiter, $this->getParts());
51
-    }
43
+	/**
44
+	 * Returns a raw mime-dir representation of the value.
45
+	 *
46
+	 * @return string
47
+	 */
48
+	public function getRawMimeDirValue()
49
+	{
50
+		return implode($this->delimiter, $this->getParts());
51
+	}
52 52
 
53
-    /**
54
-     * Returns the type of value.
55
-     *
56
-     * This corresponds to the VALUE= parameter. Every property also has a
57
-     * 'default' valueType.
58
-     *
59
-     * @return string
60
-     */
61
-    public function getValueType()
62
-    {
63
-        return 'PERIOD';
64
-    }
53
+	/**
54
+	 * Returns the type of value.
55
+	 *
56
+	 * This corresponds to the VALUE= parameter. Every property also has a
57
+	 * 'default' valueType.
58
+	 *
59
+	 * @return string
60
+	 */
61
+	public function getValueType()
62
+	{
63
+		return 'PERIOD';
64
+	}
65 65
 
66
-    /**
67
-     * Sets the json value, as it would appear in a jCard or jCal object.
68
-     *
69
-     * The value must always be an array.
70
-     */
71
-    public function setJsonValue(array $value)
72
-    {
73
-        $value = array_map(
74
-            function ($item) {
75
-                return strtr(implode('/', $item), [':' => '', '-' => '']);
76
-            },
77
-            $value
78
-        );
79
-        parent::setJsonValue($value);
80
-    }
66
+	/**
67
+	 * Sets the json value, as it would appear in a jCard or jCal object.
68
+	 *
69
+	 * The value must always be an array.
70
+	 */
71
+	public function setJsonValue(array $value)
72
+	{
73
+		$value = array_map(
74
+			function ($item) {
75
+				return strtr(implode('/', $item), [':' => '', '-' => '']);
76
+			},
77
+			$value
78
+		);
79
+		parent::setJsonValue($value);
80
+	}
81 81
 
82
-    /**
83
-     * Returns the value, in the format it should be encoded for json.
84
-     *
85
-     * This method must always return an array.
86
-     *
87
-     * @return array
88
-     */
89
-    public function getJsonValue()
90
-    {
91
-        $return = [];
92
-        foreach ($this->getParts() as $item) {
93
-            list($start, $end) = explode('/', $item, 2);
82
+	/**
83
+	 * Returns the value, in the format it should be encoded for json.
84
+	 *
85
+	 * This method must always return an array.
86
+	 *
87
+	 * @return array
88
+	 */
89
+	public function getJsonValue()
90
+	{
91
+		$return = [];
92
+		foreach ($this->getParts() as $item) {
93
+			list($start, $end) = explode('/', $item, 2);
94 94
 
95
-            $start = DateTimeParser::parseDateTime($start);
95
+			$start = DateTimeParser::parseDateTime($start);
96 96
 
97
-            // This is a duration value.
98
-            if ('P' === $end[0]) {
99
-                $return[] = [
100
-                    $start->format('Y-m-d\\TH:i:s'),
101
-                    $end,
102
-                ];
103
-            } else {
104
-                $end = DateTimeParser::parseDateTime($end);
105
-                $return[] = [
106
-                    $start->format('Y-m-d\\TH:i:s'),
107
-                    $end->format('Y-m-d\\TH:i:s'),
108
-                ];
109
-            }
110
-        }
97
+			// This is a duration value.
98
+			if ('P' === $end[0]) {
99
+				$return[] = [
100
+					$start->format('Y-m-d\\TH:i:s'),
101
+					$end,
102
+				];
103
+			} else {
104
+				$end = DateTimeParser::parseDateTime($end);
105
+				$return[] = [
106
+					$start->format('Y-m-d\\TH:i:s'),
107
+					$end->format('Y-m-d\\TH:i:s'),
108
+				];
109
+			}
110
+		}
111 111
 
112
-        return $return;
113
-    }
112
+		return $return;
113
+	}
114 114
 
115
-    /**
116
-     * This method serializes only the value of a property. This is used to
117
-     * create xCard or xCal documents.
118
-     *
119
-     * @param Xml\Writer $writer XML writer
120
-     */
121
-    protected function xmlSerializeValue(Xml\Writer $writer)
122
-    {
123
-        $writer->startElement(strtolower($this->getValueType()));
124
-        $value = $this->getJsonValue();
125
-        $writer->writeElement('start', $value[0][0]);
115
+	/**
116
+	 * This method serializes only the value of a property. This is used to
117
+	 * create xCard or xCal documents.
118
+	 *
119
+	 * @param Xml\Writer $writer XML writer
120
+	 */
121
+	protected function xmlSerializeValue(Xml\Writer $writer)
122
+	{
123
+		$writer->startElement(strtolower($this->getValueType()));
124
+		$value = $this->getJsonValue();
125
+		$writer->writeElement('start', $value[0][0]);
126 126
 
127
-        if ('P' === $value[0][1][0]) {
128
-            $writer->writeElement('duration', $value[0][1]);
129
-        } else {
130
-            $writer->writeElement('end', $value[0][1]);
131
-        }
127
+		if ('P' === $value[0][1][0]) {
128
+			$writer->writeElement('duration', $value[0][1]);
129
+		} else {
130
+			$writer->writeElement('end', $value[0][1]);
131
+		}
132 132
 
133
-        $writer->endElement();
134
-    }
133
+		$writer->endElement();
134
+	}
135 135
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
     public function setJsonValue(array $value)
72 72
     {
73 73
         $value = array_map(
74
-            function ($item) {
74
+            function($item) {
75 75
                 return strtr(implode('/', $item), [':' => '', '-' => '']);
76 76
             },
77 77
             $value
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Property/ICalendar/Duration.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -18,62 +18,62 @@
 block discarded – undo
18 18
  */
19 19
 class Duration extends Property
20 20
 {
21
-    /**
22
-     * In case this is a multi-value property. This string will be used as a
23
-     * delimiter.
24
-     *
25
-     * @var string
26
-     */
27
-    public $delimiter = ',';
21
+	/**
22
+	 * In case this is a multi-value property. This string will be used as a
23
+	 * delimiter.
24
+	 *
25
+	 * @var string
26
+	 */
27
+	public $delimiter = ',';
28 28
 
29
-    /**
30
-     * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
31
-     *
32
-     * This has been 'unfolded', so only 1 line will be passed. Unescaping is
33
-     * not yet done, but parameters are not included.
34
-     *
35
-     * @param string $val
36
-     */
37
-    public function setRawMimeDirValue($val)
38
-    {
39
-        $this->setValue(explode($this->delimiter, $val));
40
-    }
29
+	/**
30
+	 * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
31
+	 *
32
+	 * This has been 'unfolded', so only 1 line will be passed. Unescaping is
33
+	 * not yet done, but parameters are not included.
34
+	 *
35
+	 * @param string $val
36
+	 */
37
+	public function setRawMimeDirValue($val)
38
+	{
39
+		$this->setValue(explode($this->delimiter, $val));
40
+	}
41 41
 
42
-    /**
43
-     * Returns a raw mime-dir representation of the value.
44
-     *
45
-     * @return string
46
-     */
47
-    public function getRawMimeDirValue()
48
-    {
49
-        return implode($this->delimiter, $this->getParts());
50
-    }
42
+	/**
43
+	 * Returns a raw mime-dir representation of the value.
44
+	 *
45
+	 * @return string
46
+	 */
47
+	public function getRawMimeDirValue()
48
+	{
49
+		return implode($this->delimiter, $this->getParts());
50
+	}
51 51
 
52
-    /**
53
-     * Returns the type of value.
54
-     *
55
-     * This corresponds to the VALUE= parameter. Every property also has a
56
-     * 'default' valueType.
57
-     *
58
-     * @return string
59
-     */
60
-    public function getValueType()
61
-    {
62
-        return 'DURATION';
63
-    }
52
+	/**
53
+	 * Returns the type of value.
54
+	 *
55
+	 * This corresponds to the VALUE= parameter. Every property also has a
56
+	 * 'default' valueType.
57
+	 *
58
+	 * @return string
59
+	 */
60
+	public function getValueType()
61
+	{
62
+		return 'DURATION';
63
+	}
64 64
 
65
-    /**
66
-     * Returns a DateInterval representation of the Duration property.
67
-     *
68
-     * If the property has more than one value, only the first is returned.
69
-     *
70
-     * @return \DateInterval
71
-     */
72
-    public function getDateInterval()
73
-    {
74
-        $parts = $this->getParts();
75
-        $value = $parts[0];
65
+	/**
66
+	 * Returns a DateInterval representation of the Duration property.
67
+	 *
68
+	 * If the property has more than one value, only the first is returned.
69
+	 *
70
+	 * @return \DateInterval
71
+	 */
72
+	public function getDateInterval()
73
+	{
74
+		$parts = $this->getParts();
75
+		$value = $parts[0];
76 76
 
77
-        return DateTimeParser::parseDuration($value);
78
-    }
77
+		return DateTimeParser::parseDuration($value);
78
+	}
79 79
 }
Please login to merge, or discard this patch.