Config   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 10 1
A isNativeSvgActivated() 0 7 3
1
<?php
2
/**
3
 * Nextcloud - Gallery
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 2017
11
 */
12
13
namespace OCA\Gallery\Controller;
14
15
use OCP\ILogger;
0 ignored issues
show
Bug introduced by
The type OCP\ILogger was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
use OCP\AppFramework\Http;
0 ignored issues
show
Bug introduced by
The type OCP\AppFramework\Http was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
use OCA\Gallery\Service\ConfigService;
20
21
/**
22
 * Trait Config
23
 *
24
 * @package OCA\Gallery\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
	private function getConfig($extraMediaTypes = false) {
47
		$features = $this->configService->getFeaturesList();
48
49
		//$this->logger->debug("Features: {features}", ['features' => $features]);
50
51
		$nativeSvgSupport = $this->isNativeSvgActivated($features);
52
		$mediaTypes =
53
			$this->configService->getSupportedMediaTypes($extraMediaTypes, $nativeSvgSupport);
54
55
		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
	private function isNativeSvgActivated($features) {
66
		$nativeSvgSupport = false;
67
		if (!empty($features) && in_array('native_svg', $features)) {
68
			$nativeSvgSupport = true;
69
		}
70
71
		return $nativeSvgSupport;
72
	}
73
}
74