Completed
Push — master ( 441551...71e206 )
by Sebastian
05:58
created

Version   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 82
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getVersionNumber() 0 11 3
A id() 0 9 2
A getVersionString() 0 4 1
1
<?php
2
namespace phpbu\App;
3
4
use SebastianBergmann;
5
6
/**
7
 * Application Version.
8
 *
9
 * @package    phpbu
10
 * @subpackage App
11
 * @author     Sebastian Feldmann <[email protected]>
12
 * @copyright  Sebastian Feldmann <[email protected]>
13
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
14
 * @link       http://phpbu.de/
15
 * @since      Class available since Release 1.0.0
16
 */
17
class Version
18
{
19
    /**
20
     * Current version
21
     *
22
     * @var string
23
     */
24
    private static $version;
25
26
    /**
27
     * Path to application root directory.
28
     *
29
     * @var string
30
     */
31
    private $path;
32
33
    /**
34
     * Current release version.
35
     *
36
     * @var string
37
     */
38
    private $release;
39
40
    /**
41
     * Current version number.
42
     *
43
     * @var string
44
     */
45
    private $number;
46
47
    /**
48
     * @param string $release
49
     * @param string $path
50
     */
51 3
    public function __construct($release, $path)
52
    {
53 3
        $this->release = $release;
54 3
        $this->path    = $path;
55 3
    }
56
57
    /**
58
     * Return the full version number.
59
     *
60
     * @return string
61
     */
62 3
    public function getVersionNumber()
63
    {
64 3
        if ($this->number === null) {
65 3
            if (count(explode('.', $this->release)) == 3) {
66 1
                $this->number = $this->release;
67
            } else {
68 2
                $this->number = $this->release . '-dev';
69
            }
70
        }
71 3
        return $this->number;
72
    }
73
74
    /**
75
     * Return the current version of PHPUnit.
76
     *
77
     * @return string
78
     */
79 2
    public static function id() : string
80
    {
81 2
        if (self::$version === null) {
82 1
            $version = new self('5.1', dirname(dirname(__DIR__)));
83 1
            self::$version = $version->getVersionNumber();
84
        }
85
86 2
        return self::$version;
87
    }
88
89
    /**
90
     * Return the version string.
91
     *
92
     * @return string
93
     */
94 1
    public static function getVersionString() : string
95
    {
96 1
        return 'phpbu ' . self::id() . ' by Sebastian Feldmann and contributors.';
97
    }
98
}
99