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

NotHtmlRoute   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A matches() 0 7 1
A buildOutputPath() 0 8 2
A buildRelativeUrl() 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\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