]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/VObject/Parameter.php
Move friendica-specific parts into an own subdirectory
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / VObject / Parameter.php
1 <?php
2
3 /**
4  * VObject Parameter
5  *
6  * This class represents a parameter. A parameter is always tied to a property.
7  * In the case of:
8  *   DTSTART;VALUE=DATE:20101108
9  * VALUE=DATE would be the parameter name and value.
10  *
11  * @package Sabre
12  * @subpackage VObject
13  * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
14  * @author Evert Pot (http://www.rooftopsolutions.nl/)
15  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
16  */
17 class Sabre_VObject_Parameter extends Sabre_VObject_Node {
18
19     /**
20      * Parameter name
21      *
22      * @var string
23      */
24     public $name;
25
26     /**
27      * Parameter value
28      *
29      * @var string
30      */
31     public $value;
32
33     /**
34      * Sets up the object
35      *
36      * @param string $name
37      * @param string $value
38      */
39     public function __construct($name, $value = null) {
40
41         $this->name = strtoupper($name);
42         $this->value = $value;
43
44     }
45
46     /**
47      * Turns the object back into a serialized blob.
48      *
49      * @return string
50      */
51     public function serialize() {
52
53         if (is_null($this->value)) {
54             return $this->name;
55         }
56         $src = array(
57             '\\',
58             "\n",
59             ';',
60             ',',
61         );
62         $out = array(
63             '\\\\',
64             '\n',
65             '\;',
66             '\,',
67         );
68
69         return $this->name . '=' . str_replace($src, $out, $this->value);
70
71     }
72
73     /**
74      * Called when this object is being cast to a string
75      *
76      * @return string
77      */
78     public function __toString() {
79
80         return $this->value;
81
82     }
83
84 }