Passed
Push — master ( c85748...2fd0ab )
by Petr
08:11
created

AFile   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
c 1
b 0
f 1
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A deleteRecord() 0 11 3
1
<?php
2
3
namespace kalanis\kw_mapper\Mappers\Storage;
4
5
6
use kalanis\kw_mapper\MapperException;
7
use kalanis\kw_mapper\Mappers\Shared\TFile;
8
use kalanis\kw_mapper\Records\ARecord;
9
use kalanis\kw_mapper\Records\PageRecord;
10
use kalanis\kw_storage\StorageException;
11
12
13
/**
14
 * Class AFile
15
 * @package kalanis\kw_mapper\Mappers\Storage
16
 * Abstract layer for working with single files as content source
17
 */
18
abstract class AFile extends AStorage
19
{
20
    use TFile;
21
22
    /**
23
     * @param ARecord|PageRecord $record
24
     * @throws MapperException
25
     * @return bool
26
     */
27 2
    protected function deleteRecord(ARecord $record): bool
28
    {
29 2
        $path = strval($record->offsetGet($this->getPathFromPk($record)));
30
        try {
31 2
            if ($this->getStorage()->exists($path)) {
32 2
                return $this->getStorage()->remove($path);
33
            }
34 1
        } catch (StorageException $ex) {
35 1
            return false;
36
        }
37 1
        return true; // not found - operation successful
38
    }
39
}
40