Completed
Push — master ( b1cbf9...c194c3 )
by Roberto
16:10 queued 14:03
created

FilesFolders::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 9.4285
cc 1
eloc 9
nc 1
nop 1
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
            'file' => [
16 2
                'public' => 0755,
17
                'private' => 0700
18 3
            ],
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