ApplicationHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 26
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getApplicationVersion() 0 5 1
1
<?php
2
3
declare(strict_types = 1);
4
5
/**
6
 * Copyright 2020 SURFnet B.V.
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *     http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
20
21
namespace Surfnet\StepupSelfService\SelfServiceBundle\Service;
22
23
use Surfnet\StepupSelfService\SelfServiceBundle\Assert;
24
25
class ApplicationHelper
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ApplicationHelper
Loading history...
26
{
27
    private $kernelProjectDir;
0 ignored issues
show
Coding Style introduced by
Private member variable "kernelProjectDir" must be prefixed with an underscore
Loading history...
28
29
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
30
     * @param string $kernelProjectDir
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
31
     */
32
    public function __construct($kernelProjectDir)
33
    {
34
        Assert::string($kernelProjectDir, 'Kernel project directory must have a string value');
35
        $this->kernelProjectDir = $kernelProjectDir;
36
    }
37
38
    /**
39
     * In stepup application, the installation path includes the software version. This is the version that can be
40
     * read on the `/info` endpoint.
41
     *
42
     * For development builds, this will probably simply be Stepup-SelfService
43
     *
44
     * @return string
45
     */
46
    public function getApplicationVersion(): string
47
    {
48
        // The buildPath (version string) is the installation directory of the project. And is derived from the
49
        // kernel.project_dir (which is the app folder).
50
        return basename(realpath($this->kernelProjectDir));
51
    }
52
}
53