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

FileSnapshot   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 47
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A path() 0 4 1
A id() 0 4 1
A size() 0 4 1
A timestamp() 0 4 1
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
}