Completed
Pull Request — master (#87)
by Roeland
26:41 queued 21:21
created

Application   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 45
ccs 24
cts 26
cp 0.9231
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setupWrapper() 0 33 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
20
class Application extends App {
21
22
	const APP_NAME = 'files_antivirus';
23
24 5
	public function __construct (array $urlParams = []) {
25 5
		parent::__construct(self::APP_NAME, $urlParams);
26 5
	}
27
	
28
	/**
29
	 * Add wrapper for local storages
30
	 */
31 1
	public function setupWrapper(){
32 1
		\OC\Files\Filesystem::addStorageWrapper(
33 1
			'oc_avir',
34 1
			function ($mountPoint, $storage) {
35
				/**
36
				 * @var \OC\Files\Storage\Storage $storage
37
				 */
38 1
				if ($storage->instanceOfStorage(Jail::class)) {
39
					// No reason to wrap jails again
40
					return $storage;
41
				}
42
43 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...
44 1
					$container = $this->getContainer();
45 1
					$scannerFactory = $container->query(ScannerFactory::class);
46 1
					$l10n = $container->query(IL10N::class);
47 1
					$logger = $container->query(ILogger::class);
48 1
					$activityManager = $container->query(IManager::class);
49 1
					return new AvirWrapper([
50 1
						'storage' => $storage,
51 1
						'scannerFactory' => $scannerFactory,
52 1
						'l10n' => $l10n,
53 1
						'logger' => $logger,
54 1
						'activityManager' => $activityManager,
55 1
						'isHomeStorage' => $storage->instanceOfStorage(IHomeStorage::class),
56
					]);
57
				}
58
59
				return $storage;
60 1
			},
61 1
			1
62
		);
63 1
	}
64
}
65