Issues (195)

lib/Model/DetectionDeserializer.php (2 issues)

Labels
Severity
1
<?php
2
/**
3
 * @copyright Copyright (c) 2019 Matthias Held <[email protected]>
4
 * @author Matthias Held <[email protected]>
5
 * @license GNU AGPL version 3 or any later version
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License as
9
 * published by the Free Software Foundation, either version 3 of the
10
 * License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License
18
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
 */
20
21
namespace OCA\RansomwareDetection\Model;
22
23
use OCA\RansomwareDetection\Db\FileOperationMapper;
24
25
class DetectionDeserializer {
26
27
    /** @var FileOperationMapper */
28
    protected $mapper;
29
30
    /**
31
     * @param FileOperationMapper $mapper
32
     */
33
    public function __construct(
34
        FileOperationMapper $mapper
35
    ) {
36
        $this->mapper = $mapper;
37
    }
38
39
    public function deserialize($json) {
40
        $detection = new Detection();
0 ignored issues
show
The call to OCA\RansomwareDetection\...etection::__construct() has too few arguments starting with id. ( Ignorable by Annotation )

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

40
        $detection = /** @scrutinizer ignore-call */ new Detection();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
41
        $detection->setId($json['id']);
42
        foreach ($json['fileOperations'] as $fileOperation) {
43
            $detection->addFileOperation($this->mapper->find($fileOperation->getId()));
0 ignored issues
show
The call to OCA\RansomwareDetection\...OperationMapper::find() has too few arguments starting with userId. ( Ignorable by Annotation )

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

43
            $detection->addFileOperation($this->mapper->/** @scrutinizer ignore-call */ find($fileOperation->getId()));

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
44
        }   
45
        return $detection;
46
    }
47
}