@@ -25,7 +25,6 @@ class Configurator {
2525 */
2626 private $ environment ;
2727
28-
2928 public function run ($ input ,
3029 $ output ,
3130 $ environment ,
@@ -91,13 +90,6 @@ function addJSConfig($environment, $filename) {
9190 }
9291 }
9392
94- /**
95- * @param $data
96- */
97- // private function addConfig($data) {
98- // $this->config = array_merge($this->config, $data);
99- // }
100-
10193 private function addConfigDefault ($ data ) {
10294 $ this ->configDefault = array_merge ($ this ->configDefault , $ data );
10395 }
@@ -110,7 +102,6 @@ private function addConfigOverride($data) {
110102 $ this ->configOverride = array_merge ($ this ->configOverride , $ data );
111103 }
112104
113-
114105 /**
115106 * Adds an ini file to the configurator. All of the options are then available for
116107 * generating config files from.
@@ -123,12 +114,15 @@ public function addPHPConfig($environment, $filename) {
123114 $ contents = ob_get_contents ();
124115 ob_end_clean ();
125116
126-
127117 if (strlen ($ contents ) != 0 ) {
128- echo "Filename ` " .$ filename ."` output some characters. Please check it is a valid PHP file. \n" ;
118+
119+ $ message = sprintf (
120+ "Filename `%s` output some characters. Please check it is a valid PHP file. \n" ,
121+ $ filename
122+ );
123+
124+ throw new ConfiguratorException ($ message );
129125 }
130-
131- //var_dump($default);
132126
133127 if (isset ($ default ) == true ) {
134128 $ this ->addConfigDefault ($ default );
@@ -141,6 +135,11 @@ public function addPHPConfig($environment, $filename) {
141135 if (isset ($ override ) == true ) {
142136 $ this ->addConfigOverride ($ override );
143137 }
138+
139+ if (isset ($ evaluate ) == true ) {
140+ $ calculatedValues = $ evaluate ($ this ->getConfig ());
141+ $ this ->addConfigOverride ($ calculatedValues );
142+ }
144143 }
145144
146145
@@ -154,7 +153,7 @@ public function addPHPConfig($environment, $filename) {
154153 */
155154 public function addConstant ($ constantName ) {
156155 if (defined ($ constantName ) == false ) {
157- throw new \Exception ("Constant [ $ constantName] is not available, cannot configurate. " );
156+ throw new \ConfiguratorException ("Constant [ $ constantName] is not available, cannot configurate. " );
158157 }
159158
160159 $ this ->config [$ constantName ] = constant ($ constantName );
@@ -176,12 +175,7 @@ public function addConfigValue($name, $value){
176175 * @param $inputFilename
177176 * @return mixed
178177 */
179- public function configurate ($ inputFilename ) {
180- // $config = $this->config;
181- // $config = array_merge($config, $this->configDefault);
182- // $config = array_merge($config, $this->configEnvironment);
183- // $config = array_merge($config, $this->configOverride);
184-
178+ public function configurate ($ inputFilename ) {
185179 $ config = $ this ->getConfig ();
186180
187181 foreach ($ config as $ key => $ value ) {
0 commit comments