ApplicationInfo::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Apie\ApplicationInfoPlugin\ApiResources;
4
5
use Apie\ApplicationInfoPlugin\DataLayers\ApplicationInfoRetriever;
6
use Apie\Core\Annotations\ApiResource;
7
8
/**
9
 * Creates an application_info api resource. It's best practice to have an end point to tell what application this REST API is.
10
 * Other use cases are to see if multiple REST API's work in the same environment, etc.
11
 *
12
 * @ApiResource(
13
 *     retrieveClass=ApplicationInfoRetriever::class
14
 * )
15
 */
16
class ApplicationInfo
17
{
18
    /**
19
     * @var string
20
     */
21
    private $appName;
22
23
    /**
24
     * @var string
25
     */
26
    private $environment;
27
28
    /**
29
     * @var string
30
     */
31
    private $hash;
32
33
    /**
34
     * @var bool
35
     */
36
    private $debug;
37
38
    /**
39
     * @param string $appName
40
     * @param string $environment
41
     * @param string $hash
42
     * @param bool $debug
43
     */
44
    public function __construct(string $appName, string $environment, string $hash, bool $debug)
45
    {
46
        $this->appName = $appName;
47
        $this->environment = $environment;
48
        $this->hash = $hash;
49
        $this->debug = $debug;
50
    }
51
52
    /**
53
     * Returns the application name.
54
     *
55
     * @return string
56
     */
57
    public function getAppName(): string
58
    {
59
        return $this->appName;
60
    }
61
62
    /**
63
     * Returns the environment, e.g. development, production, etc.
64
     *
65
     * @return string
66
     */
67
    public function getEnvironment(): string
68
    {
69
        return $this->environment;
70
    }
71
72
    /**
73
     * Returns some arbitrary hash to find out which version is live, for example a git hash, composer version....
74
     *
75
     * @return string
76
     */
77
    public function getHash(): string
78
    {
79
        return $this->hash;
80
    }
81
82
    /**
83
     * Returns true if debug mode is on.
84
     *
85
     * @return bool
86
     */
87
    public function isDebug(): bool
88
    {
89
        return $this->debug;
90
    }
91
}
92