<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
/** @var bool */
protected $primary;
- /**
- * Constructor
- */
public function __construct() {
$this->label = '';
$this->labelParsed = '';
* @throws \InvalidArgumentException if the label is invalid
* @since 8.2.0
*/
- public function setLabel($label) {
- if (!is_string($label) || $label === '' || isset($label[32])) {
+ public function setLabel(string $label): IAction {
+ if ($label === '' || isset($label[32])) {
throw new \InvalidArgumentException('The given label is invalid');
}
$this->label = $label;
* @return string
* @since 8.2.0
*/
- public function getLabel() {
+ public function getLabel(): string {
return $this->label;
}
* @throws \InvalidArgumentException if the label is invalid
* @since 8.2.0
*/
- public function setParsedLabel($label) {
- if (!is_string($label) || $label === '') {
+ public function setParsedLabel(string $label): IAction {
+ if ($label === '') {
throw new \InvalidArgumentException('The given parsed label is invalid');
}
$this->labelParsed = $label;
* @return string
* @since 8.2.0
*/
- public function getParsedLabel() {
+ public function getParsedLabel(): string {
return $this->labelParsed;
}
/**
* @param $primary bool
* @return $this
- * @throws \InvalidArgumentException if $primary is invalid
* @since 9.0.0
*/
- public function setPrimary($primary) {
- if (!is_bool($primary)) {
- throw new \InvalidArgumentException('The given primary option is invalid');
- }
-
+ public function setPrimary(bool $primary): IAction {
$this->primary = $primary;
return $this;
}
* @return bool
* @since 9.0.0
*/
- public function isPrimary() {
+ public function isPrimary(): bool {
return $this->primary;
}
* @throws \InvalidArgumentException if the link is invalid
* @since 8.2.0
*/
- public function setLink($link, $requestType) {
- if (!is_string($link) || $link === '' || isset($link[256])) {
+ public function setLink(string $link, string $requestType): IAction {
+ if ($link === '' || isset($link[256])) {
throw new \InvalidArgumentException('The given link is invalid');
}
- if (!in_array($requestType, ['GET', 'POST', 'PUT', 'DELETE'], true)) {
+ if (!in_array($requestType, [
+ self::TYPE_GET,
+ self::TYPE_POST,
+ self::TYPE_PUT,
+ self::TYPE_DELETE,
+ self::TYPE_WEB,
+ ], true)) {
throw new \InvalidArgumentException('The given request type is invalid');
}
$this->link = $link;
* @return string
* @since 8.2.0
*/
- public function getLink() {
+ public function getLink(): string {
return $this->link;
}
* @return string
* @since 8.2.0
*/
- public function getRequestType() {
+ public function getRequestType(): string {
return $this->requestType;
}
/**
* @return bool
*/
- public function isValid() {
+ public function isValid(): bool {
return $this->label !== '' && $this->link !== '';
}
/**
* @return bool
*/
- public function isValidParsed() {
+ public function isValidParsed(): bool {
return $this->labelParsed !== '' && $this->link !== '';
}
}
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
/** @var bool */
protected $preparingPushNotification;
- /**
- * Manager constructor.
- *
- * @param IValidator $validator
- */
public function __construct(IValidator $validator) {
$this->validator = $validator;
$this->apps = [];
* @param bool $preparingPushNotification
* @since 14.0.0
*/
- public function setPreparingPushNotification($preparingPushNotification) {
+ public function setPreparingPushNotification(bool $preparingPushNotification): void {
$this->preparingPushNotification = $preparingPushNotification;
}
* @throws \InvalidArgumentException When the notification is not valid
* @since 8.2.0
*/
- public function notify(INotification $notification) {
+ public function notify(INotification $notification): void {
if (!$notification->isValid()) {
throw new \InvalidArgumentException('The given notification is invalid');
}
* @throws \InvalidArgumentException When the notification was not prepared by a notifier
* @since 8.2.0
*/
- public function prepare(INotification $notification, $languageCode): INotification {
+ public function prepare(INotification $notification, string $languageCode): INotification {
$notifiers = $this->getNotifiers();
foreach ($notifiers as $notifier) {
/**
* @param INotification $notification
*/
- public function markProcessed(INotification $notification) {
+ public function markProcessed(INotification $notification): void {
$apps = $this->getApps();
foreach ($apps as $app) {
<?php
-declare (strict_types = 1);
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
/** @var bool */
protected $hasPrimaryParsedAction;
- /**
- * Constructor
- *
- * @param IValidator $richValidator
- */
public function __construct(IValidator $richValidator) {
$this->richValidator = $richValidator;
$this->app = '';
* @throws \InvalidArgumentException if the app id is invalid
* @since 8.2.0
*/
- public function setApp(string $app) {
- if (trim($app) === '' || isset($app[32])) {
+ public function setApp(string $app): INotification {
+ if ($app === '' || isset($app[32])) {
throw new \InvalidArgumentException('The given app name is invalid');
}
$this->app = $app;
* @return string
* @since 8.2.0
*/
- public function getApp() {
+ public function getApp(): string {
return $this->app;
}
* @throws \InvalidArgumentException if the user id is invalid
* @since 8.2.0
*/
- public function setUser(string $user) {
- if (trim($user) === '' || isset($user[64])) {
+ public function setUser(string $user): INotification {
+ if ($user === '' || isset($user[64])) {
throw new \InvalidArgumentException('The given user id is invalid');
}
$this->user = $user;
* @return string
* @since 8.2.0
*/
- public function getUser() {
+ public function getUser(): string {
return $this->user;
}
* @throws \InvalidArgumentException if the $dateTime is invalid
* @since 9.0.0
*/
- public function setDateTime(\DateTime $dateTime) {
+ public function setDateTime(\DateTime $dateTime): INotification {
if ($dateTime->getTimestamp() === 0) {
throw new \InvalidArgumentException('The given date time is invalid');
}
* @return \DateTime
* @since 9.0.0
*/
- public function getDateTime() {
+ public function getDateTime(): \DateTime {
return $this->dateTime;
}
* @throws \InvalidArgumentException if the object type or id is invalid
* @since 8.2.0 - 9.0.0: Type of $id changed to string
*/
- public function setObject(string $type, $id) {
- if (trim($type) === '' || isset($type[64])) {
+ public function setObject(string $type, string $id): INotification {
+ if ($type === '' || isset($type[64])) {
throw new \InvalidArgumentException('The given object type is invalid');
}
$this->objectType = $type;
- if (!is_int($id) && (!is_string($id) || $id === '' || isset($id[64]))) {
+ if ($id === '' || isset($id[64])) {
throw new \InvalidArgumentException('The given object id is invalid');
}
$this->objectId = (string) $id;
* @return string
* @since 8.2.0
*/
- public function getObjectType() {
+ public function getObjectType(): string {
return $this->objectType;
}
* @return string
* @since 8.2.0 - 9.0.0: Return type changed to string
*/
- public function getObjectId() {
+ public function getObjectId(): string {
return $this->objectId;
}
* @throws \InvalidArgumentException if the subject or parameters are invalid
* @since 8.2.0
*/
- public function setSubject(string $subject, array $parameters = []) {
- if (trim($subject) === '' || isset($subject[64])) {
+ public function setSubject(string $subject, array $parameters = []): INotification {
+ if ($subject === '' || isset($subject[64])) {
throw new \InvalidArgumentException('The given subject is invalid');
}
* @return string
* @since 8.2.0
*/
- public function getSubject() {
+ public function getSubject(): string {
return $this->subject;
}
/**
- * @return string[]
+ * @return array
* @since 8.2.0
*/
- public function getSubjectParameters() {
+ public function getSubjectParameters(): array {
return $this->subjectParameters;
}
* @throws \InvalidArgumentException if the subject is invalid
* @since 8.2.0
*/
- public function setParsedSubject(string $subject) {
- if (trim($subject) === '') {
+ public function setParsedSubject(string $subject): INotification {
+ if ($subject === '') {
throw new \InvalidArgumentException('The given parsed subject is invalid');
}
$this->subjectParsed = $subject;
* @return string
* @since 8.2.0
*/
- public function getParsedSubject() {
+ public function getParsedSubject(): string {
return $this->subjectParsed;
}
* @throws \InvalidArgumentException if the subject or parameters are invalid
* @since 11.0.0
*/
- public function setRichSubject(string $subject, array $parameters = []) {
- if (trim($subject) === '') {
+ public function setRichSubject(string $subject, array $parameters = []): INotification {
+ if ($subject === '') {
throw new \InvalidArgumentException('The given parsed subject is invalid');
}
* @return string
* @since 11.0.0
*/
- public function getRichSubject() {
+ public function getRichSubject(): string {
return $this->subjectRich;
}
* @return array[]
* @since 11.0.0
*/
- public function getRichSubjectParameters() {
+ public function getRichSubjectParameters(): array {
return $this->subjectRichParameters;
}
* @throws \InvalidArgumentException if the message or parameters are invalid
* @since 8.2.0
*/
- public function setMessage(string $message, array $parameters = []) {
- if (trim($message) === '' || isset($message[64])) {
+ public function setMessage(string $message, array $parameters = []): INotification {
+ if ($message === '' || isset($message[64])) {
throw new \InvalidArgumentException('The given message is invalid');
}
* @return string
* @since 8.2.0
*/
- public function getMessage() {
+ public function getMessage(): string {
return $this->message;
}
/**
- * @return string[]
+ * @return array
* @since 8.2.0
*/
- public function getMessageParameters() {
+ public function getMessageParameters(): array {
return $this->messageParameters;
}
* @throws \InvalidArgumentException if the message is invalid
* @since 8.2.0
*/
- public function setParsedMessage(string $message) {
- if (trim($message) === '') {
+ public function setParsedMessage(string $message): INotification {
+ if ($message === '') {
throw new \InvalidArgumentException('The given parsed message is invalid');
}
$this->messageParsed = $message;
* @return string
* @since 8.2.0
*/
- public function getParsedMessage() {
+ public function getParsedMessage(): string {
return $this->messageParsed;
}
* @throws \InvalidArgumentException if the message or parameters are invalid
* @since 11.0.0
*/
- public function setRichMessage(string $message, array $parameters = []) {
- if (trim($message) === '') {
+ public function setRichMessage(string $message, array $parameters = []): INotification {
+ if ($message === '') {
throw new \InvalidArgumentException('The given parsed message is invalid');
}
* @return string
* @since 11.0.0
*/
- public function getRichMessage() {
+ public function getRichMessage(): string {
return $this->messageRich;
}
* @return array[]
* @since 11.0.0
*/
- public function getRichMessageParameters() {
+ public function getRichMessageParameters(): array {
return $this->messageRichParameters;
}
* @throws \InvalidArgumentException if the link is invalid
* @since 8.2.0
*/
- public function setLink(string $link) {
- if (trim($link) === '' || isset($link[4000])) {
+ public function setLink(string $link): INotification {
+ if ($link === '' || isset($link[4000])) {
throw new \InvalidArgumentException('The given link is invalid');
}
$this->link = $link;
* @return string
* @since 8.2.0
*/
- public function getLink() {
+ public function getLink(): string {
return $this->link;
}
* @throws \InvalidArgumentException if the icon is invalid
* @since 11.0.0
*/
- public function setIcon(string $icon) {
- if (trim($icon) === '' || isset($icon[4000])) {
+ public function setIcon(string $icon): INotification {
+ if ($icon === '' || isset($icon[4000])) {
throw new \InvalidArgumentException('The given icon is invalid');
}
$this->icon = $icon;
* @return string
* @since 11.0.0
*/
- public function getIcon() {
+ public function getIcon(): string {
return $this->icon;
}
* @return IAction
* @since 8.2.0
*/
- public function createAction() {
+ public function createAction(): IAction {
return new Action();
}
* @throws \InvalidArgumentException if the action is invalid
* @since 8.2.0
*/
- public function addAction(IAction $action) {
+ public function addAction(IAction $action): INotification {
if (!$action->isValid()) {
throw new \InvalidArgumentException('The given action is invalid');
}
* @return IAction[]
* @since 8.2.0
*/
- public function getActions() {
+ public function getActions(): array {
return $this->actions;
}
* @throws \InvalidArgumentException if the action is invalid
* @since 8.2.0
*/
- public function addParsedAction(IAction $action) {
+ public function addParsedAction(IAction $action): INotification {
if (!$action->isValidParsed()) {
throw new \InvalidArgumentException('The given parsed action is invalid');
}
* @return IAction[]
* @since 8.2.0
*/
- public function getParsedActions() {
+ public function getParsedActions(): array {
return $this->actionsParsed;
}
* @return bool
* @since 8.2.0
*/
- public function isValid() {
+ public function isValid(): bool {
return
$this->isValidCommon()
&&
* @return bool
* @since 8.2.0
*/
- public function isValidParsed() {
+ public function isValidParsed(): bool {
if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
try {
$this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
;
}
- /**
- * @return bool
- */
- protected function isValidCommon() {
+ protected function isValidCommon(): bool {
return
$this->getApp() !== ''
&&
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @since 9.0.0
*/
interface IAction {
+
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_GET = 'GET';
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_POST = 'POST';
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_PUT = 'PUT';
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_DELETE = 'DELETE';
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_WEB = 'WEB';
+
/**
* @param string $label
* @return $this
* @throws \InvalidArgumentException if the label is invalid
* @since 9.0.0
*/
- public function setLabel($label);
+ public function setLabel(string $label): IAction;
/**
* @return string
* @since 9.0.0
*/
- public function getLabel();
+ public function getLabel(): string;
/**
* @param string $label
* @throws \InvalidArgumentException if the label is invalid
* @since 9.0.0
*/
- public function setParsedLabel($label);
+ public function setParsedLabel(string $label): IAction;
/**
* @return string
* @since 9.0.0
*/
- public function getParsedLabel();
+ public function getParsedLabel(): string;
/**
- * @param $primary bool
+ * @param bool $primary
* @return $this
* @throws \InvalidArgumentException if $primary is invalid
* @since 9.0.0
*/
- public function setPrimary($primary);
+ public function setPrimary(bool $primary): IAction;
/**
* @return bool
* @since 9.0.0
*/
- public function isPrimary();
+ public function isPrimary(): bool;
/**
* @param string $link
* @throws \InvalidArgumentException if the link is invalid
* @since 9.0.0
*/
- public function setLink($link, $requestType);
+ public function setLink(string $link, string $requestType): IAction;
/**
* @return string
* @since 9.0.0
*/
- public function getLink();
+ public function getLink(): string;
/**
* @return string
* @since 9.0.0
*/
- public function getRequestType();
+ public function getRequestType(): string;
/**
* @return bool
* @since 9.0.0
*/
- public function isValid();
+ public function isValid(): bool;
/**
* @return bool
* @since 9.0.0
*/
- public function isValidParsed();
+ public function isValidParsed(): bool;
}
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @throws \InvalidArgumentException When the notification is not valid
* @since 9.0.0
*/
- public function notify(INotification $notification);
+ public function notify(INotification $notification): void;
/**
* @param INotification $notification
* @since 9.0.0
*/
- public function markProcessed(INotification $notification);
+ public function markProcessed(INotification $notification): void;
/**
* @param INotification $notification
* @return int
* @since 9.0.0
*/
- public function getCount(INotification $notification);
+ public function getCount(INotification $notification): int;
}
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @return array App ID => App Name
* @since 9.0.0
*/
- public function listNotifiers();
+ public function listNotifiers(): array;
/**
* @return INotification
* @since 9.0.0
*/
- public function createNotification();
+ public function createNotification(): INotification;
/**
* @return bool
* @since 9.0.0
*/
- public function hasNotifiers();
+ public function hasNotifiers(): bool;
/**
* @param bool $preparingPushNotification
* @since 14.0.0
*/
- public function setPreparingPushNotification($preparingPushNotification);
+ public function setPreparingPushNotification(bool $preparingPushNotification): void;
/**
* @return bool
* @since 14.0.0
*/
- public function isPreparingPushNotification();
+ public function isPreparingPushNotification(): bool;
}
<?php
-declare (strict_types = 1);
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @throws \InvalidArgumentException if the app id is invalid
* @since 9.0.0
*/
- public function setApp(string $app);
+ public function setApp(string $app): INotification;
/**
* @return string
* @since 9.0.0
*/
- public function getApp();
+ public function getApp(): string;
/**
* @param string $user
* @throws \InvalidArgumentException if the user id is invalid
* @since 9.0.0
*/
- public function setUser(string $user);
+ public function setUser(string $user): INotification;
/**
* @return string
* @since 9.0.0
*/
- public function getUser();
+ public function getUser(): string;
/**
* @param \DateTime $dateTime
* @throws \InvalidArgumentException if the $dateTime is invalid
* @since 9.0.0
*/
- public function setDateTime(\DateTime $dateTime);
+ public function setDateTime(\DateTime $dateTime): INotification;
/**
* @return \DateTime
* @since 9.0.0
*/
- public function getDateTime();
+ public function getDateTime(): \DateTime;
/**
* @param string $type
* @throws \InvalidArgumentException if the object type or id is invalid
* @since 9.0.0
*/
- public function setObject(string $type, $id);
+ public function setObject(string $type, string $id): INotification;
/**
* @return string
* @since 9.0.0
*/
- public function getObjectType();
+ public function getObjectType(): string;
/**
* @return string
* @since 9.0.0
*/
- public function getObjectId();
+ public function getObjectId(): string;
/**
* @param string $subject
* @throws \InvalidArgumentException if the subject or parameters are invalid
* @since 9.0.0
*/
- public function setSubject(string $subject, array $parameters = []);
+ public function setSubject(string $subject, array $parameters = []): INotification;
/**
* @return string
* @since 9.0.0
*/
- public function getSubject();
+ public function getSubject(): string;
/**
- * @return string[]
+ * @return array
* @since 9.0.0
*/
- public function getSubjectParameters();
+ public function getSubjectParameters(): array;
/**
* Set a parsed subject
* @throws \InvalidArgumentException if the subject is invalid
* @since 9.0.0
*/
- public function setParsedSubject(string $subject);
+ public function setParsedSubject(string $subject): INotification;
/**
* @return string
* @since 9.0.0
*/
- public function getParsedSubject();
+ public function getParsedSubject(): string;
/**
* Set a RichObjectString subject
* @throws \InvalidArgumentException if the subject or parameters are invalid
* @since 11.0.0
*/
- public function setRichSubject(string $subject, array $parameters = []);
+ public function setRichSubject(string $subject, array $parameters = []): INotification;
/**
* @return string
* @since 11.0.0
*/
- public function getRichSubject();
+ public function getRichSubject(): string;
/**
* @return array[]
* @since 11.0.0
*/
- public function getRichSubjectParameters();
+ public function getRichSubjectParameters(): array;
/**
* @param string $message
* @throws \InvalidArgumentException if the message or parameters are invalid
* @since 9.0.0
*/
- public function setMessage(string $message, array $parameters = []);
+ public function setMessage(string $message, array $parameters = []): INotification;
/**
* @return string
* @since 9.0.0
*/
- public function getMessage();
+ public function getMessage(): string;
/**
- * @return string[]
+ * @return array
* @since 9.0.0
*/
- public function getMessageParameters();
+ public function getMessageParameters(): array;
/**
* Set a parsed message
* @throws \InvalidArgumentException if the message is invalid
* @since 9.0.0
*/
- public function setParsedMessage(string $message);
+ public function setParsedMessage(string $message): INotification;
/**
* @return string
* @since 9.0.0
*/
- public function getParsedMessage();
+ public function getParsedMessage(): string;
/**
* Set a RichObjectString message
* @throws \InvalidArgumentException if the message or parameters are invalid
* @since 11.0.0
*/
- public function setRichMessage(string $message, array $parameters = []);
+ public function setRichMessage(string $message, array $parameters = []): INotification;
/**
* @return string
* @since 11.0.0
*/
- public function getRichMessage();
+ public function getRichMessage(): string;
/**
* @return array[]
* @since 11.0.0
*/
- public function getRichMessageParameters();
+ public function getRichMessageParameters(): array;
/**
* @param string $link
* @throws \InvalidArgumentException if the link is invalid
* @since 9.0.0
*/
- public function setLink(string $link);
+ public function setLink(string $link): INotification;
/**
* @return string
* @since 9.0.0
*/
- public function getLink();
+ public function getLink(): string;
/**
* @param string $icon
* @throws \InvalidArgumentException if the icon is invalid
* @since 11.0.0
*/
- public function setIcon(string $icon);
+ public function setIcon(string $icon): INotification;
/**
* @return string
* @since 11.0.0
*/
- public function getIcon();
+ public function getIcon(): string;
/**
* @return IAction
* @since 9.0.0
*/
- public function createAction();
+ public function createAction(): IAction;
/**
* @param IAction $action
* @throws \InvalidArgumentException if the action is invalid
* @since 9.0.0
*/
- public function addAction(IAction $action);
+ public function addAction(IAction $action): INotification;
/**
* @return IAction[]
* @since 9.0.0
*/
- public function getActions();
+ public function getActions(): array;
/**
* @param IAction $action
* @throws \InvalidArgumentException if the action is invalid
* @since 9.0.0
*/
- public function addParsedAction(IAction $action);
+ public function addParsedAction(IAction $action): INotification;
/**
* @return IAction[]
* @since 9.0.0
*/
- public function getParsedActions();
+ public function getParsedActions(): array;
/**
* @return bool
* @since 9.0.0
*/
- public function isValid();
+ public function isValid(): bool;
/**
* @return bool
* @since 9.0.0
*/
- public function isValidParsed();
+ public function isValidParsed(): bool;
}
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @throws \InvalidArgumentException When the notification was not prepared by a notifier
* @since 9.0.0
*/
- public function prepare(INotification $notification, $languageCode);
+ public function prepare(INotification $notification, string $languageCode): INotification;
}