1<?php
2
3declare(strict_types=1);
4
5
6/**
7 * Circles - Bring cloud-users closer together.
8 *
9 * This file is licensed under the Affero General Public License version 3 or
10 * later. See the COPYING file.
11 *
12 * @author Maxence Lange <maxence@artificial-owl.com>
13 * @copyright 2021
14 * @license GNU AGPL version 3 or any later version
15 *
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as
18 * published by the Free Software Foundation, either version 3 of the
19 * License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 * GNU Affero General Public License for more details.
25 *
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28 *
29 */
30
31
32namespace OCA\Circles\Model;
33
34use ArtificialOwl\MySmallPhpTools\IDeserializable;
35use ArtificialOwl\MySmallPhpTools\Traits\TArrayTools;
36use JsonSerializable;
37
38/**
39 * Class Report
40 *
41 * @package OCA\Circles\Model
42 */
43class Report implements IDeserializable, JsonSerializable {
44	use TArrayTools;
45
46	/** @var string */
47	private $source = '';
48
49	/** @var Circle[] */
50	private $circles = [];
51
52	/** @var array */
53	private $obfuscated = [];
54
55
56	/**
57	 * Report constructor.
58	 */
59	public function __construct() {
60	}
61
62
63	/**
64	 * @param string $source
65	 *
66	 * @return Report
67	 */
68	public function setSource(string $source): self {
69		$this->source = $source;
70
71		return $this;
72	}
73
74	/**
75	 * @return string
76	 */
77	public function getSource(): string {
78		return $this->source;
79	}
80
81
82	/**
83	 * @param Circle[] $circles
84	 *
85	 * @return $this
86	 */
87	public function setCircles(array $circles): self {
88		$this->circles = $circles;
89
90		return $this;
91	}
92
93	/**
94	 * @return Circle[]
95	 */
96	public function getCircles(): array {
97		return $this->circles;
98	}
99
100
101	/**
102	 * @param array $obfuscated
103	 *
104	 * @return $this
105	 */
106	public function setObfuscated(array $obfuscated): self {
107		$this->obfuscated = $obfuscated;
108
109		return $this;
110	}
111
112	/**
113	 * @return array
114	 */
115	public function getObfuscated(): array {
116		return $this->obfuscated;
117	}
118
119
120	/**
121	 * @param array $data
122	 *
123	 * @return IDeserializable
124	 */
125	public function import(array $data): IDeserializable {
126		$this->setSource($this->get('source', $data));
127		$this->setCircles($this->getArray('circles', $data));
128		$this->setObfuscated($this->getArray('obfuscated', $data));
129
130		return $this;
131	}
132
133
134	/**
135	 * @return array
136	 */
137	public function jsonSerialize(): array {
138		return [
139			'source' => $this->getSource(),
140			'circles' => $this->getCircles(),
141			'obfuscated' => $this->getObfuscated()
142		];
143	}
144}
145