@@ -110,175 +110,76 @@ public function getParent(): ?self
110110 return $ this ->parent ;
111111 }
112112
113- /**
114- * Returns the percentage of classes that has been tested.
115- *
116- * @return float|string
117- */
118- public function getTestedClassesPercent (bool $ asString = true )
113+ public function getTestedClassesPercent (): Percentage
119114 {
120- $ percentage = Percentage::fromFractionAndTotal (
115+ return Percentage::fromFractionAndTotal (
121116 $ this ->getNumTestedClasses (),
122117 $ this ->getNumClasses (),
123118 );
124-
125- if ($ asString ) {
126- return $ percentage ->asString ();
127- }
128-
129- return $ percentage ->asFloat ();
130119 }
131120
132- /**
133- * Returns the percentage of traits that has been tested.
134- *
135- * @return float|string
136- */
137- public function getTestedTraitsPercent (bool $ asString = true )
121+ public function getTestedTraitsPercent (): Percentage
138122 {
139- $ percentage = Percentage::fromFractionAndTotal (
123+ return Percentage::fromFractionAndTotal (
140124 $ this ->getNumTestedTraits (),
141125 $ this ->getNumTraits (),
142126 );
143-
144- if ($ asString ) {
145- return $ percentage ->asString ();
146- }
147-
148- return $ percentage ->asFloat ();
149127 }
150128
151- /**
152- * Returns the percentage of classes and traits that has been tested.
153- *
154- * @return float|string
155- */
156- public function getTestedClassesAndTraitsPercent (bool $ asString = true )
129+ public function getTestedClassesAndTraitsPercent (): Percentage
157130 {
158- $ percentage = Percentage::fromFractionAndTotal (
131+ return Percentage::fromFractionAndTotal (
159132 $ this ->getNumTestedClassesAndTraits (),
160133 $ this ->getNumClassesAndTraits (),
161134 );
162-
163- if ($ asString ) {
164- return $ percentage ->asString ();
165- }
166-
167- return $ percentage ->asFloat ();
168135 }
169136
170- /**
171- * Returns the percentage of functions that has been tested.
172- *
173- * @return float|string
174- */
175- public function getTestedFunctionsPercent (bool $ asString = true )
137+ public function getTestedFunctionsPercent (): Percentage
176138 {
177- $ percentage = Percentage::fromFractionAndTotal (
139+ return Percentage::fromFractionAndTotal (
178140 $ this ->getNumTestedFunctions (),
179141 $ this ->getNumFunctions (),
180142 );
181-
182- if ($ asString ) {
183- return $ percentage ->asString ();
184- }
185-
186- return $ percentage ->asFloat ();
187143 }
188144
189- /**
190- * Returns the percentage of methods that has been tested.
191- *
192- * @return float|string
193- */
194- public function getTestedMethodsPercent (bool $ asString = true )
145+ public function getTestedMethodsPercent (): Percentage
195146 {
196- $ percentage = Percentage::fromFractionAndTotal (
147+ return Percentage::fromFractionAndTotal (
197148 $ this ->getNumTestedMethods (),
198149 $ this ->getNumMethods (),
199150 );
200-
201- if ($ asString ) {
202- return $ percentage ->asString ();
203- }
204-
205- return $ percentage ->asFloat ();
206151 }
207152
208- /**
209- * Returns the percentage of functions and methods that has been tested.
210- *
211- * @return float|string
212- */
213- public function getTestedFunctionsAndMethodsPercent (bool $ asString = true )
153+ public function getTestedFunctionsAndMethodsPercent (): Percentage
214154 {
215- $ percentage = Percentage::fromFractionAndTotal (
155+ return Percentage::fromFractionAndTotal (
216156 $ this ->getNumTestedFunctionsAndMethods (),
217157 $ this ->getNumFunctionsAndMethods (),
218158 );
219-
220- if ($ asString ) {
221- return $ percentage ->asString ();
222- }
223-
224- return $ percentage ->asFloat ();
225159 }
226160
227- /**
228- * Returns the percentage of executed lines.
229- *
230- * @return float|string
231- */
232- public function getLineExecutedPercent (bool $ asString = true )
161+ public function getLineExecutedPercent (): Percentage
233162 {
234- $ percentage = Percentage::fromFractionAndTotal (
163+ return Percentage::fromFractionAndTotal (
235164 $ this ->getNumExecutedLines (),
236165 $ this ->getNumExecutableLines (),
237166 );
238-
239- if ($ asString ) {
240- return $ percentage ->asString ();
241- }
242-
243- return $ percentage ->asFloat ();
244167 }
245168
246- /**
247- * Returns the percentage of executed branches.
248- *
249- * @return float|string
250- */
251- public function getBranchExecutedPercent (bool $ asString = true )
169+ public function getBranchExecutedPercent (): Percentage
252170 {
253- $ percentage = Percentage::fromFractionAndTotal (
171+ return Percentage::fromFractionAndTotal (
254172 $ this ->getNumExecutedBranches (),
255173 $ this ->getNumExecutableBranches ()
256174 );
257-
258- if ($ asString ) {
259- return $ percentage ->asString ();
260- }
261-
262- return $ percentage ->asFloat ();
263175 }
264176
265- /**
266- * Returns the percentage of executed paths.
267- *
268- * @return float|string
269- */
270- public function getPathExecutedPercent (bool $ asString = true )
177+ public function getPathExecutedPercent (): Percentage
271178 {
272- $ percentage = Percentage::fromFractionAndTotal (
179+ return Percentage::fromFractionAndTotal (
273180 $ this ->getNumExecutedPaths (),
274181 $ this ->getNumExecutablePaths ()
275182 );
276-
277- if ($ asString ) {
278- return $ percentage ->asString ();
279- }
280-
281- return $ percentage ->asFloat ();
282183 }
283184
284185 /**
0 commit comments