Completed
Push — master ( 7c9e2e...904e9e )
by Dmitry
11:28 queued 05:32
created

Cache::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.3755

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 15
ccs 6
cts 11
cp 0.5455
rs 9.4285
cc 2
eloc 10
nc 2
nop 2
crap 2.3755
1
<?php
2
3
namespace Basis\Job\Tarantool;
4
5
use Basis\Filesystem;
6
use Basis\Job;
7
use Tarantool\Mapper\Mapper;
8
9
class Cache extends Job
10
{
11 1
    public function run(Mapper $mapper, Filesystem $fs)
12
    {
13 1
        $filename = $fs->getPath('.cache/mapper-meta.php');
14
15 1
        $dir = dirname($filename);
16 1
        if (!is_dir($dir)) {
17 1
            mkdir($dir);
18 1
            chown($dir, 'www-data');
19
            chgrp($dir, 'www-data');
20
        }
21
22
        file_put_contents($filename, '<?php return '.var_export($mapper->getMeta(), true).';');
23
        chown($filename, 'www-data');
24
        chgrp($filename, 'www-data');
25
    }
26
}
27