GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Pull Request — master (#15)
by Jan
03:12
created

ProjectVersionSlot::getProjectVersionService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace KamiYang\ProjectVersion\Backend\ToolbarItems;
5
6
/*
7
 * This file is part of the ProjectVersion project.
8
 *
9
 * It is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation, either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * For the full copyright and license information, please read
15
 * LICENSE file that was distributed with this source code.
16
 */
17
18
use KamiYang\ProjectVersion\Facade\CommandUtilityFacade;
19
use KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade;
20
use KamiYang\ProjectVersion\Service\ProjectVersionService;
21
use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem;
22
use TYPO3\CMS\Core\Localization\LanguageService;
23
use TYPO3\CMS\Core\SingletonInterface;
24
use TYPO3\CMS\Core\Utility\GeneralUtility;
25
use TYPO3\CMS\Core\Utility\StringUtility;
26
27
/**
28
 * Class ProjectVersionSlot
29
 */
30
final class ProjectVersionSlot implements SingletonInterface
31
{
32
    /**
33
     * @param \TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem $pObj
34
     */
35
    public function getProjectVersion(SystemInformationToolbarItem $pObj): void
36
    {
37
        $projectVersion = $this->getProjectVersionService()->getProjectVersion();
38
39
        $version = $projectVersion->getVersion();
40
41
        if (StringUtility::beginsWith($version, 'LLL:')) {
42
            $version = GeneralUtility::makeInstance(LanguageService::class)->sL($version);
43
        }
44
45
        $pObj->addSystemInformation(
46
            $projectVersion->getTitle(),
47
            $version,
48
            $projectVersion->getIconIdentifier()
49
        );
50
    }
51
52
    /**
53
     * @return \KamiYang\ProjectVersion\Service\ProjectVersionService
54
     */
55
    protected function getProjectVersionService(): ProjectVersionService
56
    {
57
        $commandUtility = GeneralUtility::makeInstance(CommandUtilityFacade::class);
58
        $systemEnvironmentBuilder = GeneralUtility::makeInstance(SystemEnvironmentBuilderFacade::class);
59
60
        return GeneralUtility::makeInstance(
61
            ProjectVersionService::class,
62
            $commandUtility,
63
            $systemEnvironmentBuilder
64
        );
65
    }
66
}
67