Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
23 liveuser 1
<?php
2
 
3
class NumberFormat {
4
 
5
	private $prefix;
6
	/**
7
	 * What will be displayed before the number
8
	 * @var string
9
	 */
10
	private $suffix;
11
 
12
	private $format;
13
 
14
	function __construct($prefix = NULL, $suffix = NULL, $format = NULL) {
15
		$this->prefix = $prefix;
16
		$this->suffix = $suffix;
17
		$this->format = $format;
18
	}
19
 
20
	public function getPrefix() {
21
		return $this->prefix;
22
	}
23
 
24
	/**
25
	 * Specifies what will be displayed before the number
26
	 * 
27
	 * @param string $prefix 
28
	 */
29
	public function setPrefix($prefix) {
30
		$this->prefix = $prefix;
31
	}
32
 
33
	public function getSuffix() {
34
		return $this->suffix;
35
	}
36
 
37
	/**
38
	 * Specifies what will be displayed after the number
39
	 * 
40
	 * @param string $suffix 
41
	 */
42
	public function setSuffix($suffix) {
43
		$this->suffix = $suffix;
44
	}
45
 
46
	public function getFormat() {
47
		return $this->format;
48
	}
49
 
50
	/**
51
	 * The number formats supported are as follows:
52
	 * Numeric: 1, 2, 3, ...
53
	 * Alphabetic: a, b, c, ... or A, B, C, ...
54
	 * Roman: i, ii, iii, iv, ... or I, II, III, IV,...
55
	 * The argument can be "1", "a", "A", "i", or "I". If empty, no number is displayed.
56
	 * 
57
	 * @param string $format
58
	 */
59
	public function setFormat($format) {
60
		switch ($format) {
61
			case '1':
62
			case 'a':
63
			case 'A':
64
			case 'i':
65
			case 'I':
66
				$this->format = $format;
67
			default:
68
				throw new Exception('Invalid num-format value');
69
		}
70
 
71
	}
72
 
73
 
74
}
75
?>