Completed
Push — master ( 10b6a2...f41058 )
by Valentin
09:40 queued 06:06
created

FileSnapshot::size()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Spiral\Snapshotter\FileHandler\Entities;
4
5
class FileSnapshot
6
{
7
    /** @var string */
8
    private $filename;
9
10
    /**
11
     * FileSnapshot constructor.
12
     *
13
     * @param string $filename
14
     */
15
    public function __construct(string $filename)
16
    {
17
        $this->filename = $filename;
18
    }
19
20
    /**
21
     * @return string
22
     */
23
    public function path(): string
24
    {
25
        return $this->filename;
26
    }
27
28
    /**
29
     * @return string
30
     */
31
    public function id(): string
32
    {
33
        return basename($this->filename);
34
    }
35
36
    /**
37
     * @return int
38
     */
39
    public function size(): int
40
    {
41
        return filesize($this->filename);
42
    }
43
44
    /**
45
     * @return FileTimestamp
46
     */
47
    public function timestamp(): FileTimestamp
48
    {
49
        return new FileTimestamp(filemtime($this->filename), []);
50
    }
51
}