FileHooks::deleteTrack()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Audio Player
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the LICENSE.md file.
7
 *
8
 * @author Marcel Scherello <[email protected]>
9
 * @copyright 2016-2021 Marcel Scherello
10
 */
11
 
12
namespace OCA\audioplayer\Hooks;
13
use OCA\audioplayer\Controller;
14
use \OCP\Files\FileInfo;
0 ignored issues
show
Bug introduced by
The type \OCP\Files\FileInfo 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...
15
use Psr\Log\LoggerInterface;
16
17
class FileHooks {
18
19
    private $logger;
20
21
    public function __construct(LoggerInterface $logger) {
22
        $this->logger = $logger;
23
    }
24
25
    /**
26
     * delete track from library after file deletion
27
     * @param array $params
28
     * @throws \OCP\AppFramework\QueryException
29
     */
30
	public static function deleteTrack($params) {
31
32
		$view = \OC\Files\Filesystem::getView();
33
		$node = $view->getFileInfo($params['path']);
34
35
        #$this->logger->debug('Hook delete id: '.$node->getId(), array('app' => 'audioplayer'));
36
		if ($node->getType() === FileInfo::TYPE_FILE) {
37
			$app = new \OCA\audioplayer\AppInfo\Application();
38
        	$container = $app->getContainer();
39
            $container->query(\OCA\audioplayer\Controller\DbController::class)->deleteFromDB($node->getId());
0 ignored issues
show
Deprecated Code introduced by
The function OCP\IContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

39
            /** @scrutinizer ignore-deprecated */ $container->query(\OCA\audioplayer\Controller\DbController::class)->deleteFromDB($node->getId());

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

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

Loading history...
40
		}
41
	}    
42
}
43