nextcloud/lib/private/Notification/Action.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

121 lines
2.2 KiB
PHP
Raw Normal View History

2015-08-31 06:24:37 -04:00
<?php
declare(strict_types=1);
2015-08-31 06:24:37 -04:00
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
2015-08-31 06:24:37 -04:00
*/
namespace OC\Notification;
use OCP\Notification\IAction;
use OCP\Notification\InvalidValueException;
2015-08-31 06:24:37 -04:00
class Action implements IAction {
protected string $label = '';
protected string $labelParsed = '';
protected string $link = '';
protected string $requestType = '';
protected bool $primary = false;
2015-08-31 06:24:37 -04:00
/**
* {@inheritDoc}
2015-08-31 06:24:37 -04:00
*/
public function setLabel(string $label): IAction {
if ($label === '' || isset($label[32])) {
throw new InvalidValueException('label');
2015-08-31 06:24:37 -04:00
}
$this->label = $label;
return $this;
}
/**
* {@inheritDoc}
2015-08-31 06:24:37 -04:00
*/
public function getLabel(): string {
2015-08-31 06:24:37 -04:00
return $this->label;
}
/**
* {@inheritDoc}
2015-08-31 06:24:37 -04:00
*/
public function setParsedLabel(string $label): IAction {
if ($label === '') {
throw new InvalidValueException('parsedLabel');
2015-08-31 06:24:37 -04:00
}
$this->labelParsed = $label;
return $this;
}
/**
* {@inheritDoc}
2015-08-31 06:24:37 -04:00
*/
public function getParsedLabel(): string {
2015-08-31 06:24:37 -04:00
return $this->labelParsed;
}
2015-11-16 10:14:52 -05:00
/**
* {@inheritDoc}
2015-11-16 10:14:52 -05:00
*/
public function setPrimary(bool $primary): IAction {
2015-11-16 10:14:52 -05:00
$this->primary = $primary;
return $this;
2015-11-16 10:14:52 -05:00
}
/**
* {@inheritDoc}
2015-11-16 10:14:52 -05:00
*/
public function isPrimary(): bool {
2015-11-16 10:14:52 -05:00
return $this->primary;
}
2015-08-31 06:24:37 -04:00
/**
* {@inheritDoc}
2015-08-31 06:24:37 -04:00
*/
public function setLink(string $link, string $requestType): IAction {
if ($link === '' || isset($link[256])) {
throw new InvalidValueException('link');
2015-08-31 06:24:37 -04:00
}
if (!in_array($requestType, [
self::TYPE_GET,
self::TYPE_POST,
self::TYPE_PUT,
self::TYPE_DELETE,
self::TYPE_WEB,
], true)) {
throw new InvalidValueException('requestType');
2015-09-01 04:46:08 -04:00
}
2015-08-31 06:24:37 -04:00
$this->link = $link;
2015-09-01 11:06:38 -04:00
$this->requestType = $requestType;
2015-08-31 06:24:37 -04:00
return $this;
}
/**
* {@inheritDoc}
2015-08-31 06:24:37 -04:00
*/
public function getLink(): string {
2015-08-31 06:24:37 -04:00
return $this->link;
}
2015-09-01 06:09:39 -04:00
/**
* {@inheritDoc}
2015-09-01 06:09:39 -04:00
*/
public function getRequestType(): string {
2015-09-01 06:09:39 -04:00
return $this->requestType;
}
2015-08-31 06:24:37 -04:00
/**
* {@inheritDoc}
2015-08-31 06:24:37 -04:00
*/
public function isValid(): bool {
2015-08-31 06:24:37 -04:00
return $this->label !== '' && $this->link !== '';
}
/**
* {@inheritDoc}
2015-08-31 06:24:37 -04:00
*/
public function isValidParsed(): bool {
2015-08-31 06:24:37 -04:00
return $this->labelParsed !== '' && $this->link !== '';
}
}