Application::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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
	public const APP_NAME = 'files_antivirus';
23
24
	public function __construct(array $urlParams = []) {
25 5
		parent::__construct(self::APP_NAME, $urlParams);
26 5
	}
27 5
	
28
	/**
29
	 * Add wrapper for local storages
30
	 */
31
	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
				if ($storage->instanceOfStorage(Jail::class)) {
39 1
					// No reason to wrap jails again
40
					return $storage;
41
				}
42
43
				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);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\IContainer::query() has been deprecated with message: 20.0.0 use \Psr\Container\ContainerInterface::get

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
46 1
					$l10n = $container->query(IL10N::class);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\IContainer::query() has been deprecated with message: 20.0.0 use \Psr\Container\ContainerInterface::get

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
47 1
					$logger = $container->query(ILogger::class);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\IContainer::query() has been deprecated with message: 20.0.0 use \Psr\Container\ContainerInterface::get

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
48 1
					$activityManager = $container->query(IManager::class);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\IContainer::query() has been deprecated with message: 20.0.0 use \Psr\Container\ContainerInterface::get

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
49 1
					$eventDispatcher = $container->query(EventDispatcherInterface::class);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\IContainer::query() has been deprecated with message: 20.0.0 use \Psr\Container\ContainerInterface::get

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
50 1
					return new AvirWrapper([
51 1
						'storage' => $storage,
52 1
						'scannerFactory' => $scannerFactory,
53 1
						'l10n' => $l10n,
54 1
						'logger' => $logger,
55 1
						'activityManager' => $activityManager,
56 1
						'isHomeStorage' => $storage->instanceOfStorage(IHomeStorage::class),
57 1
						'eventDispatcher' => $eventDispatcher,
58 1
					]);
59
				}
60
61
				return $storage;
62
			},
63 1
			1
64 1
		);
65
	}
66
}
67