Completed
Pull Request — master (#10)
by Tomáš
06:04 queued 03:12
created

SourceOutput::outputId()   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 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is a part of Sculpin.
5
 *
6
 * (c) Dragonfly Development Inc.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Symplify\PHP7_Sculpin\Output;
13
14
use Symplify\PHP7_Sculpin\Permalink\Permalink;
15
use Symplify\PHP7_Sculpin\Source\SourceInterface;
16
use SplFileInfo;
17
18
final class SourceOutput
19
{
20
    /**
21
     * @var SourceInterface
22
     */
23
    private $source;
24
25 1
    public function __construct(SourceInterface $source)
26
    {
27 1
        $this->source = $source;
28 1
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function outputId() : string
34
    {
35
        return $this->source->sourceId();
36
    }
37
38
    /**
39
     * Pathname (relative).
40
     */
41
    public function pathname() : string
42
    {
43
        return $this->source->relativePathname();
44
    }
45
46
    /**
47
     * Suggested permalink.
48
     */
49 1
    public function permalink() : Permalink
50
    {
51 1
        return $this->source->permalink();
52
    }
53
54 1
    public function hasFileReference() : bool
55
    {
56 1
        return $this->source->useFileReference();
57
    }
58
59
    /**
60
     * @return SplFileInfo|null
61
     */
62 1
    public function file()
63
    {
64 1
        return $this->source->useFileReference() ? $this->source->file() : null;
65
    }
66
67
    /**
68
     * Formatted content (if not hasFileReference).
69
     *
70
     * @return string|null
71
     */
72
    public function formattedContent()
73
    {
74
        return $this->source->useFileReference() ? null : $this->source->formattedContent();
75
    }
76
}
77