EncryptedFile::setFromLocalFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 5
1
<?php
2
3
namespace LeKoala\Encrypt;
4
5
use Exception;
6
use SilverStripe\Assets\File;
7
8
/**
9
 * @mixin \LeKoala\Encrypt\EncryptedDBFile
10
 * @property bool $Encrypted
11
 * @method bool encryptFileIfNeeded()
12
 */
13
class EncryptedFile extends File
14
{
15
    /**
16
     * @return void
17
     */
18
    protected function onBeforeWrite()
19
    {
20
        parent::onBeforeWrite();
21
        try {
22
            $this->encryptFileIfNeeded(false);
0 ignored issues
show
Unused Code introduced by
The call to LeKoala\Encrypt\Encrypte...::encryptFileIfNeeded() has too many arguments starting with false. ( Ignorable by Annotation )

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

22
            $this->/** @scrutinizer ignore-call */ 
23
                   encryptFileIfNeeded(false);

This check compares calls to functions or methods with their respective definitions. If the call has more 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...
23
        } catch (Exception $ex) {
24
            $this->Encrypted = false;
25
        }
26
    }
27
28
    /**
29
     * @param string $path
30
     * @param ?string $filename
31
     * @param ?string $hash
32
     * @param ?string $variant
33
     * @param array<mixed> $config
34
     * @return array<mixed>
35
     */
36
    public function setFromLocalFile($path, $filename = null, $hash = null, $variant = null, $config = [])
37
    {
38
        $this->Encrypted = false;
39
        return parent::setFromLocalFile($path, $filename = null, $hash = null, $variant = null, $config = []);
40
    }
41
42
    /**
43
     * @param resource $stream
44
     * @param string $filename
45
     * @param ?string $hash
46
     * @param ?string $variant
47
     * @param array<mixed> $config
48
     * @return array<mixed>
49
     */
50
    public function setFromStream($stream, $filename, $hash = null, $variant = null, $config = [])
51
    {
52
        $this->Encrypted = false;
53
        return parent::setFromStream($stream, $filename, $hash = null, $variant = null, $config = []);
54
    }
55
56
    /**
57
     * @param string $data
58
     * @param string $filename
59
     * @param ?string $hash
60
     * @param ?string $variant
61
     * @param array<mixed> $config
62
     * @return array<mixed>
63
     */
64
    public function setFromString($data, $filename, $hash = null, $variant = null, $config = [])
65
    {
66
        $this->Encrypted = false;
67
        return parent::setFromString($data, $filename, $hash = null, $variant = null, $config = []);
68
    }
69
}
70