BaseEntity::getDownloadPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/GPL-3.0 GPL v3
8
 */
9
namespace AnimeDb\Bundle\AppBundle\Service\Downloader\Entity;
10
11
abstract class BaseEntity implements EntityInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    private $filename = '';
17
18
    /**
19
     * @var array
20
     */
21
    private $old_filenames = [];
22
23
    /**
24
     * @return string
25
     */
26 7
    public function getFilename()
27
    {
28 7
        return $this->filename;
29
    }
30
31
    /**
32
     * @param string $filename
33
     */
34 7
    public function setFilename($filename)
35
    {
36
        // copy current file to the old files for remove it later
37 7
        if ($this->filename) {
38 3
            $this->old_filenames[] = $this->filename;
39
        }
40 7
        $this->filename = $filename;
41 7
    }
42
43
    /**
44
     * @return array
45
     */
46 3
    public function getOldFilenames()
47
    {
48 3
        return $this->old_filenames;
49
    }
50
51
    /**
52
     * @return string
53
     */
54 4
    public function getDownloadPath()
55
    {
56 4
        return 'media';
57
    }
58
59
    /**
60
     * @return string
61
     */
62 2
    public function getWebPath()
63
    {
64 2
        return $this->getFilename() ? sprintf('/%s/%s', $this->getDownloadPath(), $this->getFilename()) : '';
65
    }
66
}
67