1<?php
2
3declare(strict_types=1);
4/**
5 * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
6 *
7 * @license GNU AGPL version 3 or any later version
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU Affero General Public License for more details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23
24namespace OCA\Talk\Model;
25
26use OCP\AppFramework\Db\Entity;
27
28/**
29 * @method void setApp(string $app)
30 * @method string getApp()
31 * @method void setName(string $name)
32 * @method string getName()
33 * @method void setCommand(string $command)
34 * @method string getCommand()
35 * @method void setScript(string $name)
36 * @method string getScript()
37 * @method void setResponse(int $response)
38 * @method int getResponse()
39 * @method void setEnabled(int $enabled)
40 * @method int getEnabled()
41 */
42class Command extends Entity {
43	public const RESPONSE_NONE = 0;
44	public const RESPONSE_USER = 1;
45	public const RESPONSE_ALL = 2;
46
47	public const ENABLED_OFF = 0;
48	public const ENABLED_MODERATOR = 1;
49	public const ENABLED_USERS = 2;
50	public const ENABLED_ALL = 3;
51
52	/** @var string */
53	protected $app;
54
55	/** @var string */
56	protected $name;
57
58	/** @var string */
59	protected $command;
60
61	/** @var string */
62	protected $script;
63
64	/** @var int */
65	protected $response;
66
67	/** @var int */
68	protected $enabled;
69
70	public function __construct() {
71		$this->addType('app', 'string');
72		$this->addType('name', 'string');
73		$this->addType('command', 'string');
74		$this->addType('script', 'string');
75		$this->addType('response', 'int');
76		$this->addType('enabled', 'int');
77	}
78
79	/**
80	 * @return array
81	 */
82	public function asArray(): array {
83		return [
84			'id' => $this->getId(),
85			'app' => $this->getApp(),
86			'name' => $this->getName(),
87			'command' => $this->getCommand(),
88			'script' => $this->getScript(),
89			'response' => $this->getResponse(),
90			'enabled' => $this->getEnabled(),
91		];
92	}
93}
94