Passed
Push — master ( 5a9348...48ccd3 )
by Thomas
03:36
created

EncryptedFile::setFromString()   A

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
 */
12
class EncryptedFile extends File
13
{
14
    protected function onBeforeWrite()
15
    {
16
        parent::onBeforeWrite();
17
        try {
18
            $this->encryptFileIfNeeded(false);
0 ignored issues
show
Bug introduced by
The method encryptFileIfNeeded() does not exist on LeKoala\Encrypt\EncryptedFile. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

18
            $this->/** @scrutinizer ignore-call */ 
19
                   encryptFileIfNeeded(false);
Loading history...
19
        } catch (Exception $ex) {
20
            $this->Encrypted = false;
21
        }
22
    }
23
24
    public function setFromLocalFile($path, $filename = null, $hash = null, $variant = null, $config = [])
25
    {
26
        $this->Encrypted = false;
27
        return parent::setFromLocalFile($path, $filename = null, $hash = null, $variant = null, $config = []);
28
    }
29
30
    public function setFromStream($stream, $filename, $hash = null, $variant = null, $config = [])
31
    {
32
        $this->Encrypted = false;
33
        return parent::setFromStream($stream, $filename, $hash = null, $variant = null, $config = []);
34
    }
35
36
    public function setFromString($data, $filename, $hash = null, $variant = null, $config = [])
37
    {
38
        $this->Encrypted = false;
39
        return parent::setFromString($data, $filename, $hash = null, $variant = null, $config = []);
40
    }
41
}
42