Passed
Push — master ( ef96ef...2a8452 )
by Roeland
13:23 queued 14s
created

JSDataService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 10 1
A __construct() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * @copyright Copyright (c) 2020, Roeland Jago Douma <[email protected]>
6
 *
7
 * @author Roeland Jago Douma <[email protected]>
8
 *
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
namespace OCA\Theming\Service;
27
28
use OCA\Theming\AppInfo\Application;
29
use OCA\Theming\ThemingDefaults;
30
use OCA\Theming\Util;
31
use OCP\IConfig;
32
33
class JSDataService implements \JsonSerializable {
34
35
	/** @var ThemingDefaults */
36
	private $themingDefaults;
37
	/** @var Util */
38
	private $util;
39
	/** @var IConfig */
40
	private $appConfig;
41
42
	public function __construct(
43
		ThemingDefaults $themingDefaults,
44
		Util $util,
45
		IConfig $appConfig
46
	) {
47
		$this->themingDefaults = $themingDefaults;
48
		$this->util = $util;
49
		$this->appConfig = $appConfig;
50
	}
51
52
	public function jsonSerialize() {
53
		return [
54
			'name' => $this->themingDefaults->getName(),
55
			'url' => $this->themingDefaults->getBaseUrl(),
56
			'slogan' => $this->themingDefaults->getSlogan(),
57
			'color' => $this->themingDefaults->getColorPrimary(),
58
			'imprintUrl' => $this->themingDefaults->getImprintUrl(),
59
			'privacyUrl' => $this->themingDefaults->getPrivacyUrl(),
60
			'inverted' => $this->util->invertTextColor($this->themingDefaults->getColorPrimary()),
61
			'cacheBuster' => $this->appConfig->getAppValue(Application::class, 'cachebuster', '0'),
62
		];
63
	}
64
}
65