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

PostFile::getFilenameWithoutDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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