Completed
Pull Request — master (#141)
by Joas
02:00
created

Application   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 92.59%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 47
ccs 25
cts 27
cp 0.9259
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setupWrapper() 0 35 3
1
<?php
2
/**
3
 * Copyright (c) 2015 Victor Dubiniuk <[email protected]>
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later.
6
 * See the COPYING-README file.
7
 */
8
9
namespace OCA\Files_Antivirus\AppInfo;
10
11
use OC\Files\Storage\Wrapper\Jail;
12
use OCA\Files_Antivirus\AvirWrapper;
13
use OCA\Files_Antivirus\Scanner\ScannerFactory;
14
use OCP\Activity\IManager;
15
use OCP\AppFramework\App;
16
use OCP\Files\IHomeStorage;
17
use OCP\IL10N;
18
use OCP\ILogger;
19
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
20
21
class Application extends App {
22
23
	const APP_NAME = 'files_antivirus';
24
25 5
	public function __construct (array $urlParams = []) {
26 5
		parent::__construct(self::APP_NAME, $urlParams);
27 5
	}
28
	
29
	/**
30
	 * Add wrapper for local storages
31
	 */
32 1
	public function setupWrapper(){
33 1
		\OC\Files\Filesystem::addStorageWrapper(
34 1
			'oc_avir',
35
			function ($mountPoint, $storage) {
36
				/**
37
				 * @var \OC\Files\Storage\Storage $storage
38
				 */
39 1
				if ($storage->instanceOfStorage(Jail::class)) {
40
					// No reason to wrap jails again
41
					return $storage;
42
				}
43
44 1
				if ($storage instanceof \OC\Files\Storage\Storage) {
0 ignored issues
show
Bug introduced by
The class OC\Files\Storage\Storage does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
45 1
					$container = $this->getContainer();
46 1
					$scannerFactory = $container->query(ScannerFactory::class);
47 1
					$l10n = $container->query(IL10N::class);
48 1
					$logger = $container->query(ILogger::class);
49 1
					$activityManager = $container->query(IManager::class);
50 1
					$eventDispatcher = $container->query(EventDispatcherInterface::class);
51 1
					return new AvirWrapper([
52 1
						'storage' => $storage,
53 1
						'scannerFactory' => $scannerFactory,
54 1
						'l10n' => $l10n,
55 1
						'logger' => $logger,
56 1
						'activityManager' => $activityManager,
57 1
						'isHomeStorage' => $storage->instanceOfStorage(IHomeStorage::class),
58 1
						'eventDispatcher' => $eventDispatcher,
59
					]);
60
				}
61
62
				return $storage;
63 1
			},
64 1
			1
65
		);
66 1
	}
67
}
68