Completed
Pull Request — stable9 (#52)
by Olivier
09:56
created

Config::isNativeSvgActivated()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 2
nop 1
crap 3
1
<?php
2
/**
3
 * ownCloud - galleryplus
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Olivier Paroz <[email protected]>
9
 *
10
 * @copyright Olivier Paroz 2016
11
 */
12
13
namespace OCA\GalleryPlus\Controller;
14
15
use OCP\ILogger;
16
17
use OCP\AppFramework\Http;
18
19
use OCA\GalleryPlus\Service\ConfigService;
20
21
/**
22
 * Trait Config
23
 *
24
 * @package OCA\GalleryPlus\Controller
25
 */
26
trait Config {
27
28
	/**
29
	 * @var ConfigService
30
	 */
31
	private $configService;
32
	/**
33
	 * @var ILogger
34
	 */
35
	private $logger;
36
37
	/**
38
	 * @NoAdminRequired
39
	 *
40
	 * Returns an app configuration array
41
	 *
42
	 * @param bool $extraMediaTypes
43
	 *
44
	 * @return array <string,null|array>
45
	 */
46 30
	private function getConfig($extraMediaTypes = false) {
47 30
		$features = $this->configService->getFeaturesList();
48
49
		//$this->logger->debug("Features: {features}", ['features' => $features]);
50
51 27
		$nativeSvgSupport = $this->isNativeSvgActivated($features);
52
		$mediaTypes =
53 27
			$this->configService->getSupportedMediaTypes($extraMediaTypes, $nativeSvgSupport);
54
55 27
		return ['features' => $features, 'mediatypes' => $mediaTypes];
56
	}
57
58
	/**
59
	 * Determines if the native SVG feature has been activated
60
	 *
61
	 * @param array $features
62
	 *
63
	 * @return bool
64
	 */
65 27
	private function isNativeSvgActivated($features) {
66 27
		$nativeSvgSupport = false;
67 27
		if (!empty($features) && in_array('native_svg', $features)) {
68 6
			$nativeSvgSupport = true;
69
		}
70
71 27
		return $nativeSvgSupport;
72
	}
73
}
74