Completed
Push — master ( 5bd517...c7b86e )
by Tomáš
08:52
created

NotHtmlRoute::buildRelativeUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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\Routing\Route;
11
12
use Symplify\PHP7_Sculpin\Contract\Renderable\Routing\Route\RouteInterface;
13
use Symplify\PHP7_Sculpin\Renderable\File\AbstractFile;
14
15
final class NotHtmlRoute implements RouteInterface
16
{
17
    public function matches(AbstractFile $file) : bool
18
    {
19
        return in_array(
20
            $file->getPrimaryExtension(),
21
            ['xml', 'rss', 'json', 'atom', 'css']
22
        );
23
    }
24
25
    public function buildOutputPath(AbstractFile $file) : string
26
    {
27
        if (in_array($file->getExtension(), ['latte', 'md'])) {
28
            return $file->getBaseName();
29
        }
30
31
        return $file->getBaseName() . '.' . $file->getPrimaryExtension();
32
    }
33
34
    public function buildRelativeUrl(AbstractFile $file) : string
35
    {
36
        return $this->buildOutputPath($file);
37
    }
38
}
39