FilesFolders::save()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace NFePHP\Esfinge\Files;
4
5
use League\Flysystem\Filesystem;
6
use League\Flysystem\Adapter\Local;
7
8
class FilesFolders
9
{
10
    protected static $filesystem;
11
    
12 3
    protected static function init($path)
13
    {
14 3
        $adapter = new Local($path, LOCK_EX, Local::DISALLOW_LINKS, [
15 1
            'file' => [
16 2
                'public' => 0755,
17
                'private' => 0700
18 2
            ],
19
            'dir' => [
20 2
                'public' => 0755,
21
                'private' => 0700
22 2
            ]
23 2
        ]);
24 3
        self::$filesystem = new Filesystem($adapter);
25 3
    }
26
    
27 3
    public static function save($path, $filename, $contents)
28
    {
29 3
        self::init($path);
30 3
        self::$filesystem->put($filename, $contents, ['visibility' => 'public']);
31 3
    }
32
}
33