VersionInfo   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 4
c 3
b 0
f 1
lcom 1
cbo 0
dl 0
loc 59
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getInfo() 0 3 1
A getVersion() 0 3 1
A getName() 0 3 1
1
<?php
2
namespace nochso\Omni;
3
4
/**
5
 * VersionInfo consists of a package name and version.
6
 */
7
final class VersionInfo {
8
	/**
9
	 * `Omni v0.1.0`.
10
	 */
11
	const INFO_FORMAT_DEFAULT = '%s v%s';
12
	/**
13
	 * `Omni 0.1.0`.
14
	 */
15
	const INFO_FORMAT_SHORT = '%s %s';
16
	/**
17
	 * `Omni (Version 0.1.0)`.
18
	 */
19
	const INFO_FORMAT_LONG = '%s (Version %s)';
20
21
	/**
22
	 * @var string
23
	 */
24
	private $version;
25
	/**
26
	 * @var string
27
	 */
28
	private $name;
29
	/**
30
	 * @var string
31
	 */
32
	private $infoFormat;
33
34
	/**
35
	 * @param string $name       Package or application name.
36
	 * @param string $version    Version without a prefix.
37
	 * @param string $infoFormat Optional format to use for `getInfo`. Defaults to `self::INFO_FORMAT_DEFAULT`
38
	 */
39
	public function __construct($name, $version, $infoFormat = self::INFO_FORMAT_DEFAULT) {
40
		$this->name = $name;
41
		$this->version = $version;
42
		$this->infoFormat = $infoFormat;
43
	}
44
45
	/**
46
	 * @return string
47
	 */
48
	public function getInfo() {
49
		return sprintf($this->infoFormat, $this->getName(), $this->getVersion());
50
	}
51
52
	/**
53
	 * @return string
54
	 */
55
	public function getVersion() {
56
		return $this->version;
57
	}
58
59
	/**
60
	 * @return string
61
	 */
62
	public function getName() {
63
		return $this->name;
64
	}
65
}
66