InternalResource::getTemp()   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
 * InternalResource.php
4
 * @author Revin Roman http://phptime.ru
5
 */
6
7
namespace rmrevin\yii\module\File\resources;
8
9
/**
10
 * Class InternalResource
11
 * @package rmrevin\yii\module\File\resources
12
 */
13
class InternalResource extends AbstractResource implements ResourceInterface
14
{
15
16
    /** @var string */
17
    private $temp;
18
19
    /**
20
     * @param string $source
21
     */
22 5
    public function setSource($source)
23
    {
24 5
        $this->temp = $source;
25
26 5
        if (!file_exists($this->temp) || !is_file($this->temp)) {
27 1
            throw new \RuntimeException('Internal resource not available');
28
        }
29 4
    }
30
31
    /**
32
     * @return string
33
     */
34 3
    public function getName()
35
    {
36 3
        return basename($this->temp);
37
    }
38
39
    /**
40
     * @return int
41
     */
42 1
    public function getSize()
43
    {
44 1
        return filesize($this->temp);
45
    }
46
47
    /**
48
     * @return string
49
     * @throws \yii\base\InvalidConfigException
50
     */
51 1
    public function getMime()
52
    {
53 1
        return \yii\helpers\FileHelper::getMimeType($this->temp);
54
    }
55
56
    /**
57
     * @return string
58
     */
59 4
    public function getTemp()
60
    {
61 4
        return $this->temp;
62
    }
63
64 3
    public function clear()
65
    {
66
        // override deleting original file
67
    }
68
}