Passed
Pull Request — master (#3)
by Valentin
03:18
created

FileSnapshot   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 39
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A path() 0 4 1
A id() 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 FileTimestamp
38
     */
39
    public function timestamp(): FileTimestamp
40
    {
41
        return new FileTimestamp(filemtime($this->filename), []);
42
    }
43
}