Completed
Push — master ( 9b25f2...d42705 )
by Tomáš
09:42 queued 07:08
created

PostFile   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 34
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getDate() 0 4 1
A getDateInFormat() 0 4 1
A getFilenameWithoutDate() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Symplify
7
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
8
 */
9
10
namespace Symplify\PHP7_Sculpin\Renderable\File;
11
12
use DateTimeInterface;
13
use SplFileInfo;
14
use Symplify\PHP7_Sculpin\Utils\PathAnalyzer;
15
16
final class PostFile extends File
17
{
18
    /**
19
     * @var DateTimeInterface
20
     */
21
    private $date;
22
23
    /**
24
     * @var string
25
     */
26
    private $filenameWithoutDate;
27
28
    public function __construct(SplFileInfo $fileInfo, string $relativeSource)
29
    {
30
        parent::__construct($fileInfo, $relativeSource);
31
        $this->date = PathAnalyzer::detectDate($this->fileInfo);
32
        $this->filenameWithoutDate = PathAnalyzer::detectFilenameWithoutDate($this->fileInfo);
33
    }
34
35
    public function getDate() : DateTimeInterface
36
    {
37
        return $this->date;
38
    }
39
40
    public function getDateInFormat(string $format) : string
41
    {
42
        return $this->date->format($format);
43
    }
44
45
    public function getFilenameWithoutDate() : string
46
    {
47
        return $this->filenameWithoutDate;
48
    }
49
}
50