Completed
Push — master ( 5042d5...896299 )
by Jan
06:27
created

HomepageController::getBanner()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 11
rs 10
1
<?php
2
3
/**
4
 * part-db version 0.1
5
 * Copyright (C) 2005 Christoph Lechner
6
 * http://www.cl-projects.de/.
7
 *
8
 * part-db version 0.2+
9
 * Copyright (C) 2009 K. Jacobs and others (see authors.php)
10
 * http://code.google.com/p/part-db/
11
 *
12
 * Part-DB Version 0.4+
13
 * Copyright (C) 2016 - 2019 Jan Böhmer
14
 * https://github.com/jbtronics
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
29
 */
30
31
namespace App\Controller;
32
33
use App\Services\GitVersionInfo;
34
use SebastianBergmann\CodeCoverage\Node\File;
0 ignored issues
show
Bug introduced by
The type SebastianBergmann\CodeCoverage\Node\File was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
36
use Symfony\Component\Cache\CacheItem;
37
use Symfony\Component\Filesystem\Filesystem;
38
use Symfony\Component\HttpKernel\KernelInterface;
39
use Symfony\Component\Routing\Annotation\Route;
40
use Symfony\Contracts\Cache\CacheInterface;
41
42
class HomepageController extends AbstractController
43
{
44
    protected $cache;
45
    protected $kernel;
46
47
    public function __construct(CacheInterface $cache, KernelInterface $kernel)
48
    {
49
        $this->cache = $cache;
50
        $this->kernel = $kernel;
51
    }
52
53
    public function getBanner() : string
54
    {
55
        $banner = $this->getParameter('banner');
56
        if (empty($banner)) {
57
            $banner_path = $this->kernel->getProjectDir()
58
                . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'banner.md';
59
60
            return file_get_contents($banner_path);
61
        }
62
63
        return $banner;
64
    }
65
66
    /**
67
     * @Route("/", name="homepage")
68
     */
69
    public function homepage(GitVersionInfo $versionInfo)
70
    {
71
        return $this->render('homepage.html.twig', [
72
            'banner' => $this->getBanner(),
73
            'git_branch' => $versionInfo->getGitBranchName(),
74
            'git_commit' => $versionInfo->getGitCommitHash()
75
        ]);
76
    }
77
}
78