NotHtmlRoute::matches()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 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 5
    public function matches(AbstractFile $file) : bool
18
    {
19 5
        return in_array(
20 5
            $file->getPrimaryExtension(),
21 5
            ['xml', 'rss', 'json', 'atom', 'css']
22
        );
23
    }
24
25 2
    public function buildOutputPath(AbstractFile $file) : string
26
    {
27 2
        if (in_array($file->getExtension(), ['latte', 'md'])) {
28 1
            return $file->getBaseName();
29
        }
30
31 2
        return $file->getBaseName() . '.' . $file->getPrimaryExtension();
32
    }
33
34 2
    public function buildRelativeUrl(AbstractFile $file) : string
35
    {
36 2
        return $this->buildOutputPath($file);
37
    }
38
}
39