forked from YetiForceCompany/iCalendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IcalendarPropertyAttach.php
48 lines (39 loc) · 1 KB
/
IcalendarPropertyAttach.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
class IcalendarPropertyAttach extends IcalendarProperty
{
public $name = 'ATTACH';
public $val_type = RFC2445_TYPE_URI;
public function construct()
{
$this->valid_parameters = [
'FMTTYPE' => RFC2445_OPTIONAL | RFC2445_ONCE,
'ENCODING' => RFC2445_OPTIONAL | RFC2445_ONCE,
'VALUE' => RFC2445_OPTIONAL | RFC2445_ONCE,
RFC2445_XNAME => RFC2445_OPTIONAL,
];
}
public function invariantHolds()
{
if (isset($this->parameters['ENCODING']) && !isset($this->parameters['VALUE'])) {
return false;
}
if (isset($this->parameters['VALUE']) && !isset($this->parameters['ENCODING'])) {
return false;
}
return true;
}
public function isValidParameter($parameter, $value)
{
$parameter = strtoupper($parameter);
if (!parent::isValidParameter($parameter, $value)) {
return false;
}
if ($parameter === 'ENCODING' && strtoupper($value) != 'BASE64') {
return false;
}
if ($parameter === 'VALUE' && strtoupper($value) != 'BINARY') {
return false;
}
return true;
}
}