summaryrefslogtreecommitdiffstats
path: root/lib/Traits/TDetails.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Traits/TDetails.php')
-rw-r--r--lib/Traits/TDetails.php143
1 files changed, 143 insertions, 0 deletions
diff --git a/lib/Traits/TDetails.php b/lib/Traits/TDetails.php
new file mode 100644
index 00000000..d26a360e
--- /dev/null
+++ b/lib/Traits/TDetails.php
@@ -0,0 +1,143 @@
+<?php
+declare(strict_types=1);
+
+
+/**
+ * Nextcloud - Social Support
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Maxence Lange <maxence@artificial-owl.com>
+ * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCA\Social\Traits;
+
+
+/**
+ * Trait TDetails
+ *
+ * @package OCA\Social\Traits
+ */
+trait TDetails {
+
+
+ /** @var array */
+ private $details = [];
+
+
+ /**
+ * @return array
+ */
+ public function getDetailsAll(): array {
+ return $this->details;
+ }
+
+ /**
+ * @param array $details
+ */
+ public function setDetailsAll(array $details) {
+ $this->details = $details;
+ }
+
+ /**
+ * @param string $detail
+ * @param string $value
+ */
+ public function setDetail(string $detail, string $value) {
+ $this->details[$detail] = $value;
+ }
+
+ /**
+ * @param string $detail
+ * @param int $value
+ */
+ public function setDetailInt(string $detail, int $value) {
+ $this->details[$detail] = $value;
+ }
+
+ /**
+ * @param string $detail
+ * @param array $value
+ */
+ public function setDetailArray(string $detail, array $value) {
+ $this->details[$detail] = $value;
+ }
+
+ /**
+ * @param string $detail
+ * @param bool $value
+ */
+ public function setDetailBool(string $detail, bool $value) {
+ $this->details[$detail] = $value;
+ }
+
+
+ /**
+ * @param string $detail
+ * @param string $value
+ */
+ public function addDetail(string $detail, string $value) {
+ if (!array_key_exists($detail, $this->details) || !is_array($this->details[$detail])) {
+ $this->details[$detail] = [];
+ }
+
+ $this->details[$detail][] = $value;
+ }
+
+ /**
+ * @param string $detail
+ * @param int $value
+ */
+ public function addDetailInt(string $detail, int $value) {
+ if (!array_key_exists($detail, $this->details) || !is_array($this->details[$detail])) {
+ $this->details[$detail] = [];
+ }
+
+ $this->details[$detail][] = $value;
+ }
+
+ /**
+ * @param string $detail
+ * @param array $value
+ */
+ public function addDetailArray(string $detail, array $value) {
+ if (!array_key_exists($detail, $this->details) || !is_array($this->details[$detail])) {
+ $this->details[$detail] = [];
+ }
+
+ $this->details[$detail][] = $value;
+ }
+
+ /**
+ * @param string $detail
+ * @param bool $value
+ */
+ public function addDetailBool(string $detail, bool $value) {
+ if (!array_key_exists($detail, $this->details) || !is_array($this->details[$detail])) {
+ $this->details[$detail] = [];
+ }
+
+ $this->details[$detail][] = $value;
+ }
+
+
+}
+