@@ -67,17 +67,43 @@ class PHP_CodeCoverage_Report_HTML
6767 public static $ templatePath ;
6868
6969 /**
70- * @param PHP_CodeCoverage $coverage
71- * @param string $target
72- * @param string $title
73- * @param string $charset
74- * @param boolean $yui
75- * @param boolean $highlight
76- * @param integer $lowUpperBound
77- * @param integer $highLowerBound
70+ * @var array
71+ */
72+ protected $ options ;
73+
74+ /**
75+ * Constructor.
76+ *
77+ * @param array $options
7878 */
79- public function process ( PHP_CodeCoverage $ coverage , $ target , $ title = '' , $ charset = ' UTF-8 ' , $ yui = TRUE , $ highlight = FALSE , $ lowUpperBound = 35 , $ highLowerBound = 70 )
79+ public function __construct ( array $ options = array () )
8080 {
81+ if (!isset ($ options ['title ' ])) {
82+ $ options ['title ' ] = '' ;
83+ }
84+
85+ if (!isset ($ options ['charset ' ])) {
86+ $ options ['charset ' ] = 'UTF-8 ' ;
87+ }
88+
89+ if (!isset ($ options ['yui ' ])) {
90+ $ options ['yui ' ] = TRUE ;
91+ }
92+
93+ if (!isset ($ options ['highlight ' ])) {
94+ $ options ['highlight ' ] = FALSE ;
95+ }
96+
97+ if (!isset ($ options ['lowUpperBound ' ])) {
98+ $ options ['lowUpperBound ' ] = 35 ;
99+ }
100+
101+ if (!isset ($ options ['highLowerBound ' ])) {
102+ $ options ['highLowerBound ' ] = 70 ;
103+ }
104+
105+ $ this ->options = $ options ;
106+
81107 self ::$ templatePath = sprintf (
82108 '%s%sHTML%sTemplate%s ' ,
83109
@@ -86,7 +112,14 @@ public function process(PHP_CodeCoverage $coverage, $target, $title = '', $chars
86112 DIRECTORY_SEPARATOR ,
87113 DIRECTORY_SEPARATOR
88114 );
115+ }
89116
117+ /**
118+ * @param PHP_CodeCoverage $coverage
119+ * @param string $target
120+ */
121+ public function process (PHP_CodeCoverage $ coverage , $ target )
122+ {
90123 $ target = PHP_CodeCoverage_Util::getDirectory ($ target );
91124 $ files = $ coverage ->getSummary ();
92125 $ commonPath = PHP_CodeCoverage_Util::reducePaths ($ files );
@@ -95,32 +128,33 @@ public function process(PHP_CodeCoverage $coverage, $target, $title = '', $chars
95128 $ commonPath , NULL
96129 );
97130
98- $ this ->addItems ($ root , $ items , $ files, $ yui , $ highlight );
131+ $ this ->addItems ($ root , $ items , $ files );
99132 $ this ->copyFiles ($ target );
100133
101134 $ root ->render (
102135 $ target ,
103- $ title ,
104- $ charset ,
105- $ lowUpperBound ,
106- $ highLowerBound
136+ $ this -> options [ ' title ' ] ,
137+ $ this -> options [ ' charset ' ] ,
138+ $ this -> options [ ' lowUpperBound ' ] ,
139+ $ this -> options [ ' highLowerBound ' ]
107140 );
108141 }
109142
110143 /**
111144 * @param PHP_CodeCoverage_Report_HTML_Node_Directory $root
112145 * @param array $items
113146 * @param array $files
114- * @param boolean $yui
115- * @param boolean $highlight
116147 */
117- protected function addItems (PHP_CodeCoverage_Report_HTML_Node_Directory $ root , array $ items , array $ files, $ yui , $ highlight )
148+ protected function addItems (PHP_CodeCoverage_Report_HTML_Node_Directory $ root , array $ items , array $ files )
118149 {
119150 foreach ($ items as $ key => $ value ) {
120151 if (substr ($ key , -2 ) == '/f ' ) {
121152 try {
122153 $ file = $ root ->addFile (
123- substr ($ key , 0 , -2 ), $ value , $ yui , $ highlight
154+ substr ($ key , 0 , -2 ),
155+ $ value ,
156+ $ this ->options ['yui ' ],
157+ $ this ->options ['highlight ' ]
124158 );
125159 }
126160
@@ -129,7 +163,7 @@ protected function addItems(PHP_CodeCoverage_Report_HTML_Node_Directory $root, a
129163 }
130164 } else {
131165 $ child = $ root ->addDirectory ($ key );
132- $ this ->addItems ($ child , $ value , $ files, $ yui , $ highlight );
166+ $ this ->addItems ($ child , $ value , $ files );
133167 }
134168 }
135169 }
0 commit comments