@@ -404,24 +404,24 @@ private function calculateStatistics(array $classes, array $traits, array $funct
404404
405405 foreach ($ this ->traits as &$ trait ) {
406406 foreach ($ trait ['methods ' ] as &$ method ) {
407- $ methodLineCoverage = $ method ['executableLines ' ] ? ($ method ['executedLines ' ] / $ method ['executableLines ' ]) * 100 : 100 ;
408- $ methodBranchCoverage = $ method ['executableBranches ' ] ? ($ method ['executedBranches ' ] / $ method ['executableBranches ' ]) * 100 : 0 ;
409- $ methodPathCoverage = $ method ['executablePaths ' ] ? ($ method ['executedPaths ' ] / $ method ['executablePaths ' ]) * 100 : 0 ;
407+ $ methodLineCoverage = $ method ['executableLines ' ] > 0 ? ($ method ['executedLines ' ] / $ method ['executableLines ' ]) * 100 : 100 ;
408+ $ methodBranchCoverage = $ method ['executableBranches ' ] > 0 ? ($ method ['executedBranches ' ] / $ method ['executableBranches ' ]) * 100 : 0 ;
409+ $ methodPathCoverage = $ method ['executablePaths ' ] > 0 ? ($ method ['executedPaths ' ] / $ method ['executablePaths ' ]) * 100 : 0 ;
410410
411- $ method ['coverage ' ] = $ methodBranchCoverage ? : $ methodLineCoverage ;
412- $ method ['crap ' ] = (new CrapIndex ($ method ['ccn ' ], $ methodPathCoverage ? : $ methodLineCoverage ))->asString ();
411+ $ method ['coverage ' ] = $ methodBranchCoverage > 0 ? $ methodBranchCoverage : $ methodLineCoverage ;
412+ $ method ['crap ' ] = (new CrapIndex ($ method ['ccn ' ], $ methodPathCoverage > 0 ? $ methodPathCoverage : $ methodLineCoverage ))->asString ();
413413
414414 $ trait ['ccn ' ] += $ method ['ccn ' ];
415415 }
416416
417417 unset($ method );
418418
419- $ traitLineCoverage = $ trait ['executableLines ' ] ? ($ trait ['executedLines ' ] / $ trait ['executableLines ' ]) * 100 : 100 ;
420- $ traitBranchCoverage = $ trait ['executableBranches ' ] ? ($ trait ['executedBranches ' ] / $ trait ['executableBranches ' ]) * 100 : 0 ;
421- $ traitPathCoverage = $ trait ['executablePaths ' ] ? ($ trait ['executedPaths ' ] / $ trait ['executablePaths ' ]) * 100 : 0 ;
419+ $ traitLineCoverage = $ trait ['executableLines ' ] > 0 ? ($ trait ['executedLines ' ] / $ trait ['executableLines ' ]) * 100 : 100 ;
420+ $ traitBranchCoverage = $ trait ['executableBranches ' ] > 0 ? ($ trait ['executedBranches ' ] / $ trait ['executableBranches ' ]) * 100 : 0 ;
421+ $ traitPathCoverage = $ trait ['executablePaths ' ] > 0 ? ($ trait ['executedPaths ' ] / $ trait ['executablePaths ' ]) * 100 : 0 ;
422422
423- $ trait ['coverage ' ] = $ traitBranchCoverage ? : $ traitLineCoverage ;
424- $ trait ['crap ' ] = (new CrapIndex ($ trait ['ccn ' ], $ traitPathCoverage ? : $ traitLineCoverage ))->asString ();
423+ $ trait ['coverage ' ] = $ traitBranchCoverage > 0 ? $ traitBranchCoverage : $ traitLineCoverage ;
424+ $ trait ['crap ' ] = (new CrapIndex ($ trait ['ccn ' ], $ traitPathCoverage > 0 ? $ traitPathCoverage : $ traitLineCoverage ))->asString ();
425425
426426 if ($ trait ['executableLines ' ] > 0 && $ trait ['coverage ' ] === 100 ) {
427427 $ this ->numTestedClasses ++;
@@ -432,24 +432,24 @@ private function calculateStatistics(array $classes, array $traits, array $funct
432432
433433 foreach ($ this ->classes as &$ class ) {
434434 foreach ($ class ['methods ' ] as &$ method ) {
435- $ methodLineCoverage = $ method ['executableLines ' ] ? ($ method ['executedLines ' ] / $ method ['executableLines ' ]) * 100 : 100 ;
436- $ methodBranchCoverage = $ method ['executableBranches ' ] ? ($ method ['executedBranches ' ] / $ method ['executableBranches ' ]) * 100 : 0 ;
437- $ methodPathCoverage = $ method ['executablePaths ' ] ? ($ method ['executedPaths ' ] / $ method ['executablePaths ' ]) * 100 : 0 ;
435+ $ methodLineCoverage = $ method ['executableLines ' ] > 0 ? ($ method ['executedLines ' ] / $ method ['executableLines ' ]) * 100 : 100 ;
436+ $ methodBranchCoverage = $ method ['executableBranches ' ] > 0 ? ($ method ['executedBranches ' ] / $ method ['executableBranches ' ]) * 100 : 0 ;
437+ $ methodPathCoverage = $ method ['executablePaths ' ] > 0 ? ($ method ['executedPaths ' ] / $ method ['executablePaths ' ]) * 100 : 0 ;
438438
439- $ method ['coverage ' ] = $ methodBranchCoverage ? : $ methodLineCoverage ;
440- $ method ['crap ' ] = (new CrapIndex ($ method ['ccn ' ], $ methodPathCoverage ? : $ methodLineCoverage ))->asString ();
439+ $ method ['coverage ' ] = $ methodBranchCoverage > 0 ? $ methodBranchCoverage : $ methodLineCoverage ;
440+ $ method ['crap ' ] = (new CrapIndex ($ method ['ccn ' ], $ methodPathCoverage > 0 ? $ methodPathCoverage : $ methodLineCoverage ))->asString ();
441441
442442 $ class ['ccn ' ] += $ method ['ccn ' ];
443443 }
444444
445445 unset($ method );
446446
447- $ classLineCoverage = $ class ['executableLines ' ] ? ($ class ['executedLines ' ] / $ class ['executableLines ' ]) * 100 : 100 ;
448- $ classBranchCoverage = $ class ['executableBranches ' ] ? ($ class ['executedBranches ' ] / $ class ['executableBranches ' ]) * 100 : 0 ;
449- $ classPathCoverage = $ class ['executablePaths ' ] ? ($ class ['executedPaths ' ] / $ class ['executablePaths ' ]) * 100 : 0 ;
447+ $ classLineCoverage = $ class ['executableLines ' ] > 0 ? ($ class ['executedLines ' ] / $ class ['executableLines ' ]) * 100 : 100 ;
448+ $ classBranchCoverage = $ class ['executableBranches ' ] > 0 ? ($ class ['executedBranches ' ] / $ class ['executableBranches ' ]) * 100 : 0 ;
449+ $ classPathCoverage = $ class ['executablePaths ' ] > 0 ? ($ class ['executedPaths ' ] / $ class ['executablePaths ' ]) * 100 : 0 ;
450450
451- $ class ['coverage ' ] = $ classBranchCoverage ? : $ classLineCoverage ;
452- $ class ['crap ' ] = (new CrapIndex ($ class ['ccn ' ], $ classPathCoverage ? : $ classLineCoverage ))->asString ();
451+ $ class ['coverage ' ] = $ classBranchCoverage > 0 ? $ classBranchCoverage : $ classLineCoverage ;
452+ $ class ['crap ' ] = (new CrapIndex ($ class ['ccn ' ], $ classPathCoverage > 0 ? $ classPathCoverage : $ classLineCoverage ))->asString ();
453453
454454 if ($ class ['executableLines ' ] > 0 && $ class ['coverage ' ] === 100 ) {
455455 $ this ->numTestedClasses ++;
@@ -459,12 +459,12 @@ private function calculateStatistics(array $classes, array $traits, array $funct
459459 unset($ class );
460460
461461 foreach ($ this ->functions as &$ function ) {
462- $ functionLineCoverage = $ function ['executableLines ' ] ? ($ function ['executedLines ' ] / $ function ['executableLines ' ]) * 100 : 100 ;
463- $ functionBranchCoverage = $ function ['executableBranches ' ] ? ($ function ['executedBranches ' ] / $ function ['executableBranches ' ]) * 100 : 0 ;
464- $ functionPathCoverage = $ function ['executablePaths ' ] ? ($ function ['executedPaths ' ] / $ function ['executablePaths ' ]) * 100 : 0 ;
462+ $ functionLineCoverage = $ function ['executableLines ' ] > 0 ? ($ function ['executedLines ' ] / $ function ['executableLines ' ]) * 100 : 100 ;
463+ $ functionBranchCoverage = $ function ['executableBranches ' ] > 0 ? ($ function ['executedBranches ' ] / $ function ['executableBranches ' ]) * 100 : 0 ;
464+ $ functionPathCoverage = $ function ['executablePaths ' ] > 0 ? ($ function ['executedPaths ' ] / $ function ['executablePaths ' ]) * 100 : 0 ;
465465
466- $ function ['coverage ' ] = $ functionBranchCoverage ? : $ functionLineCoverage ;
467- $ function ['crap ' ] = (new CrapIndex ($ function ['ccn ' ], $ functionPathCoverage ? : $ functionLineCoverage ))->asString ();
466+ $ function ['coverage ' ] = $ functionBranchCoverage > 0 ? $ functionBranchCoverage : $ functionLineCoverage ;
467+ $ function ['crap ' ] = (new CrapIndex ($ function ['ccn ' ], $ functionPathCoverage > 0 ? $ functionPathCoverage : $ functionLineCoverage ))->asString ();
468468
469469 if ($ function ['coverage ' ] === 100 ) {
470470 $ this ->numTestedFunctions ++;
0 commit comments