Typo3Provider::isGilbertsoft()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Gilbertsoft\Lib\Utility;
3
4
/*
5
 * This file is part of the "GS Library" Extension for TYPO3 CMS.
6
 *
7
 * Copyright (C) 2017 by Gilbertsoft (gilbertsoft.org)
8
 *
9
 * This program 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
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * For the full license information, please read the LICENSE file that
20
 * was distributed with this source code.
21
 *
22
 * The TYPO3 project - inspiring people to share!
23
 */
24
25
/**
26
 * TYPO3 Provider class.
27
 *
28
 * USE:
29
 * The class is intended to be used without creating an instance of it.
30
 * So: Do not instantiate - call functions with "\Gilbertsoft\TYPO3\Warranty\Utility\Typo3Provider::" prefixed the function name.
31
 * So use \Gilbertsoft\TYPO3\Warranty\Utility\Typo3Provider::[method-name] to refer to the functions, eg. '\Gilbertsoft\TYPO3\Warranty\Utility\Typo3Provider::getName()'
32
 */
33
class Typo3Provider
34
{
35
    /**
36
     * @var string $name
37
     */
38
    private static $name = null;
39
40
    /**
41
     * Returns the trimmed and lowered provider name loaded by getenv.
42
     *
43
     * @return string
44
     * @api
45
     */
46
    public static function getName()
47
    {
48
        if (is_null(self::$name)) {
49
            self::$name = trim(mb_strtolower(getenv('TYPO3_PROVIDER') ?: (getenv('REDIRECT_TYPO3_PROVIDER') ?: '')));
50
        }
51
52
        return self::$name;
53
    }
54
55
    /**
56
     * Returns TRUE if $providerName equals the loaded name.
57
     *
58
     * @return bool
59
     * @api
60
     */
61
    public static function isProvider($providerName)
62
    {
63
        return self::getName() === trim(mb_strtolower($providerName));
64
    }
65
66
    /**
67
     * Returns TRUE if the provider is Gilbertsoft
68
     *
69
     * @return bool
70
     * @api
71
     */
72
    public static function isGilbertsoft()
73
    {
74
        return self::isProvider('Gilbertsoft');
75
    }
76
}
77