1: <?php
2: /**
3: * @author Jefferson González
4: * @license MIT
5: * @link http://github.com/peg-org/peg-src Source code.
6: */
7:
8: namespace Peg\Config;
9:
10: /**
11: * Base configuration class. Every frontend's configuration helper should extend this.
12: */
13: class Settings
14: {
15:
16: // Disable constructor
17: private function __construct(){}
18:
19:
20: // The array where all settings are kept.
21: protected $settings = [
22:
23: "ExtensionName" => null,
24: "ExtensionVersion" => null,
25: "Authors" => null,
26: "Contributors" => null,
27:
28: ];
29:
30: /**
31: * Gets the value of a specific option.
32: * @param string $option
33: * @return string|bool
34: */
35: public static function Get($option)
36: {
37: return $settings[$option];
38: }
39:
40: /**
41: * Get the current extension name.
42: * @return string
43: */
44: public static function GetExtensionName()
45: {
46: return $settings["ExtensionVersion"];
47: }
48:
49: /**
50: * Get the current extension version.
51: * @return string
52: */
53: public static function GetExtensionVersion()
54: {
55: return $settings["ExtensionVersion"];
56: }
57:
58: /**
59: * Get a comma separated list of authors.
60: * @return string
61: */
62: public static function GetAuthors()
63: {
64: return $settings["Authors"];
65: }
66:
67: /**
68: * Get a comma separated list of contributors.
69: * @return string
70: */
71: public static function GetContributors()
72: {
73: return $settings["Contributors"];
74: }
75:
76: /**
77: * Set the extension name, which is used in some important parts of the
78: * code generator.
79: * @param string $name
80: */
81: public static function SetExtensionName($name)
82: {
83: $settings["ExtensionName"] = trim($name);
84: }
85:
86: /**
87: * Sets the version of the extension, which is used in some important
88: * parts of the code generator.
89: * @param string $number
90: */
91: public static function SetVersion($number)
92: {
93: $settings["ExtensionVersion"] = trim($number);
94: }
95:
96: /**
97: * Set the authors of the extension. This should be a comma
98: * seperated list with the names of the authors.
99: * @param string $authors
100: */
101: public static function SetAuthors($authors)
102: {
103: $authors = trim($authors);
104: $authors = trim($authors, ",");
105:
106: $settings["Authors"] = $authors;
107: }
108:
109: /**
110: * Set the contributors of the extension. This should be a comma
111: * seperated list with the names of the contributors.
112: * @param string $contributors
113: */
114: public static function SetContributors($contributors)
115: {
116: $authors = trim($contributors);
117: $authors = trim($contributors, ",");
118:
119: $settings["Contributors"] = $contributors;
120: }
121: }
122: