7
|
1 <?php
|
|
2
|
|
3 namespace Sabre\VObject\Property;
|
|
4
|
|
5 use
|
|
6 Sabre\VObject\Property;
|
|
7
|
|
8 /**
|
|
9 * Float property
|
|
10 *
|
|
11 * This object represents FLOAT values. These can be 1 or more floating-point
|
|
12 * numbers.
|
|
13 *
|
|
14 * @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/).
|
|
15 * @author Evert Pot (http://evertpot.com/)
|
|
16 * @license http://sabre.io/license/ Modified BSD License
|
|
17 */
|
|
18 class Float extends Property {
|
|
19
|
|
20 /**
|
|
21 * In case this is a multi-value property. This string will be used as a
|
|
22 * delimiter.
|
|
23 *
|
|
24 * @var string|null
|
|
25 */
|
|
26 public $delimiter = ';';
|
|
27
|
|
28 /**
|
|
29 * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
|
|
30 *
|
|
31 * This has been 'unfolded', so only 1 line will be passed. Unescaping is
|
|
32 * not yet done, but parameters are not included.
|
|
33 *
|
|
34 * @param string $val
|
|
35 * @return void
|
|
36 */
|
|
37 public function setRawMimeDirValue($val) {
|
|
38
|
|
39 $val = explode($this->delimiter, $val);
|
|
40 foreach($val as &$item) {
|
|
41 $item = (float)$item;
|
|
42 }
|
|
43 $this->setParts($val);
|
|
44
|
|
45 }
|
|
46
|
|
47 /**
|
|
48 * Returns a raw mime-dir representation of the value.
|
|
49 *
|
|
50 * @return string
|
|
51 */
|
|
52 public function getRawMimeDirValue() {
|
|
53
|
|
54 return implode(
|
|
55 $this->delimiter,
|
|
56 $this->getParts()
|
|
57 );
|
|
58
|
|
59 }
|
|
60
|
|
61 /**
|
|
62 * Returns the type of value.
|
|
63 *
|
|
64 * This corresponds to the VALUE= parameter. Every property also has a
|
|
65 * 'default' valueType.
|
|
66 *
|
|
67 * @return string
|
|
68 */
|
|
69 public function getValueType() {
|
|
70
|
|
71 return "FLOAT";
|
|
72
|
|
73 }
|
|
74
|
|
75 /**
|
|
76 * Returns the value, in the format it should be encoded for json.
|
|
77 *
|
|
78 * This method must always return an array.
|
|
79 *
|
|
80 * @return array
|
|
81 */
|
|
82 public function getJsonValue() {
|
|
83
|
|
84 $val = array_map(
|
|
85 function($item) {
|
|
86
|
|
87 return (float)$item;
|
|
88
|
|
89 },
|
|
90 $this->getParts()
|
|
91 );
|
|
92
|
|
93 // Special-casing the GEO property.
|
|
94 //
|
|
95 // See:
|
|
96 // http://tools.ietf.org/html/draft-ietf-jcardcal-jcal-04#section-3.4.1.2
|
|
97 if ($this->name==='GEO') {
|
|
98 return array($val);
|
|
99 } else {
|
|
100 return $val;
|
|
101 }
|
|
102
|
|
103 }
|
|
104 }
|