I would really like to see all the initialization inside the __construct class.
Furthermore, empty strings need not be initialized. "private $fname;" is enough.
There are very small amount of comments in the BuildInfo.php file.
Fields like text_array are very non-descriptive, we should rename those as well.
132 + private function getInfoForFile($fname)
133 + {
134 + /**
135 + * Get array of fields for corresponding file
136 + */
137 + foreach (array_keys($this->text_array) as $key)
138 + if ($key != 'Format-Version') {
139 + $files = glob($this->search_path."/".$key);
140 + foreach ($files as $file)
141 + if ($file == $this->search_path."/".$fname)
142 + return $this->text_array[$key];
143 + }
144 + return array();
145 + }
We can avoid this whole mumbo by putting $fname as the attribute of the class and then only hold the relevant build info data for that file in text_array attribute. That's all we need for each HTTP request anyway.
All getFieldX methods should be united in one method.
I.e. public function get($fieldName) - (if we remove $fname as suggested above)
We'll get less code, less tests, and if we would need to implement new fields, we wouldn't need to add separate method and additional tests.
Hi gesha,
Your additions look great!
Few small pointers tho:
92 === added file 'licenses/ BuildInfo. php' BuildInfo. php 1970-01-01 00:00:00 +0000 BuildInfo. php 2012-06-05 14:32:19 +0000 Format- Version" , "Files-Pattern", Launchpad- Teams", User-Data" , "License-Text"); License- Text");
93 --- licenses/
94 +++ licenses/
95 @@ -0,0 +1,207 @@
96 +<?php
97 +
98 +class BuildInfo
99 +{
100 + private $text_array = array();
101 + private $fields_defined = array("
102 + "Build-Name", "Theme", "License-Type", "OpenID-
103 + "Collect-
104 + private $multiline_vars = array("
105 + private $search_path = '';
106 + private $fname = '';
I would really like to see all the initialization inside the __construct class.
Furthermore, empty strings need not be initialized. "private $fname;" is enough.
There are very small amount of comments in the BuildInfo.php file.
Fields like text_array are very non-descriptive, we should rename those as well.
132 + private function getInfoForFile( $fname) keys($this- >text_array) as $key) >search_ path."/ ".$key) ; search_ path."/ ".$fname) text_array[ $key];
133 + {
134 + /**
135 + * Get array of fields for corresponding file
136 + */
137 + foreach (array_
138 + if ($key != 'Format-Version') {
139 + $files = glob($this-
140 + foreach ($files as $file)
141 + if ($file == $this->
142 + return $this->
143 + }
144 + return array();
145 + }
We can avoid this whole mumbo by putting $fname as the attribute of the class and then only hold the relevant build info data for that file in text_array attribute. That's all we need for each HTTP request anyway.
165 + public function getTheme($fname) getInfoForFile( $fname) ; key_exists( 'Theme' , $info))
166 + {
167 + $info = $this->
168 + if (array_
169 + return $info["Theme"];
170 + else
171 + return false;
172 + }
All getFieldX methods should be united in one method.
I.e. public function get($fieldName) - (if we remove $fname as suggested above)
We'll get less code, less tests, and if we would need to implement new fields, we wouldn't need to add separate method and additional tests.
801 === modified file 'tests/ test_click_ through_ license. py' click_through_ license. py 2012-05-17 18:44:59 +0000 click_through_ license. py 2012-06-05 14:32:19 +0000
802 --- tests/test_
803 +++ tests/test_
804 @@ -36,6 +36,9 @@
Tests fail for these 3 new tests added..