blob: e2a75bea03080158c732a5fef5dbaf154c0c897b (
plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Notification;
use OCP\Notification\IAction;
use OCP\Notification\InvalidValueException;
class Action implements IAction {
protected string $label = '';
protected string $labelParsed = '';
protected string $link = '';
protected string $requestType = '';
protected bool $primary = false;
/**
* {@inheritDoc}
*/
public function setLabel(string $label): IAction {
if ($label === '' || isset($label[32])) {
throw new InvalidValueException('label');
}
$this->label = $label;
return $this;
}
/**
* {@inheritDoc}
*/
public function getLabel(): string {
return $this->label;
}
/**
* {@inheritDoc}
*/
public function setParsedLabel(string $label): IAction {
if ($label === '') {
throw new InvalidValueException('parsedLabel');
}
$this->labelParsed = $label;
return $this;
}
/**
* {@inheritDoc}
*/
public function getParsedLabel(): string {
return $this->labelParsed;
}
/**
* {@inheritDoc}
*/
public function setPrimary(bool $primary): IAction {
$this->primary = $primary;
return $this;
}
/**
* {@inheritDoc}
*/
public function isPrimary(): bool {
return $this->primary;
}
/**
* {@inheritDoc}
*/
public function setLink(string $link, string $requestType): IAction {
if ($link === '' || isset($link[256])) {
throw new InvalidValueException('link');
}
if (!in_array($requestType, [
self::TYPE_GET,
self::TYPE_POST,
self::TYPE_PUT,
self::TYPE_DELETE,
self::TYPE_WEB,
], true)) {
throw new InvalidValueException('requestType');
}
$this->link = $link;
$this->requestType = $requestType;
return $this;
}
/**
* {@inheritDoc}
*/
public function getLink(): string {
return $this->link;
}
/**
* {@inheritDoc}
*/
public function getRequestType(): string {
return $this->requestType;
}
/**
* {@inheritDoc}
*/
public function isValid(): bool {
return $this->label !== '' && $this->link !== '';
}
/**
* {@inheritDoc}
*/
public function isValidParsed(): bool {
return $this->labelParsed !== '' && $this->link !== '';
}
}
|