Url::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 8
rs 10
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * Copyright (C)
6
 * Nathan Boiron <[email protected]>
7
 * Romain Canon <[email protected]>
8
 *
9
 * This file is part of the TYPO3 NotiZ project.
10
 * It is free software; you can redistribute it and/or modify it
11
 * under the terms of the GNU General Public License, either
12
 * version 3 of the License, or any later version.
13
 *
14
 * For the full copyright and license information, see:
15
 * http://www.gnu.org/licenses/gpl-3.0.html
16
 */
17
18
namespace CuyZ\Notiz\Core\Support;
19
20
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
21
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
22
23
class Url
24
{
25
    const DOCUMENTATION_ROOT = 'https://docs.typo3.org/p/cuyz/notiz/%s/en-us/';
26
    const DOCUMENTATION_CREATE_CUSTOM_EVENT = self::DOCUMENTATION_ROOT . '06-Administrator/02-CustomEvent/Index.html';
27
    const DOCUMENTATION_ADD_TYPOSCRIPT_DEFINITION = self::DOCUMENTATION_ROOT . '06-Administrator/01-Definition/02-AddFileDefinition.html';
28
29
    const REPOSITORY = 'https://github.com/CuyZ/NotiZ';
30
    const NEW_ISSUE = 'https://github.com/CuyZ/NotiZ/issues/new';
31
32
    const SLACK_CHANNEL = 'https://typo3.slack.com/messages/ext-notiz';
33
34
    /**
35
     * @return string
36
     */
37
    public static function documentation(): string
38
    {
39
        return self::build(self::DOCUMENTATION_ROOT);
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public static function documentationCreateCustomEvent(): string
46
    {
47
        return self::build(self::DOCUMENTATION_CREATE_CUSTOM_EVENT);
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public static function documentationTypoScriptDefinition(): string
54
    {
55
        return self::build(self::DOCUMENTATION_ADD_TYPOSCRIPT_DEFINITION);
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public static function repository(): string
62
    {
63
        return self::REPOSITORY;
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public static function newIssue(): string
70
    {
71
        return self::NEW_ISSUE;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public static function slackChannel(): string
78
    {
79
        return self::SLACK_CHANNEL;
80
    }
81
82
    /**
83
     * @param string $url
84
     * @return string
85
     */
86
    private static function build(string $url): string
87
    {
88
        $version = ExtensionManagementUtility::getExtensionVersion(NotizConstants::EXTENSION_KEY);
89
        $versionArray = VersionNumberUtility::convertVersionStringToArray($version);
90
91
        return vsprintf(
92
            $url,
93
            [$versionArray['version_main'] . '.' . $versionArray['version_sub']]
94
        );
95
    }
96
}
97