@@ -404,24 +404,24 @@ private function calculateStatistics(array $classes, array $traits, array $funct
404
404
405
405
foreach ($ this ->traits as &$ trait ) {
406
406
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 ;
410
410
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 ();
413
413
414
414
$ trait ['ccn ' ] += $ method ['ccn ' ];
415
415
}
416
416
417
417
unset($ method );
418
418
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 ;
422
422
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 ();
425
425
426
426
if ($ trait ['executableLines ' ] > 0 && $ trait ['coverage ' ] === 100 ) {
427
427
$ this ->numTestedClasses ++;
@@ -432,24 +432,24 @@ private function calculateStatistics(array $classes, array $traits, array $funct
432
432
433
433
foreach ($ this ->classes as &$ class ) {
434
434
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 ;
438
438
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 ();
441
441
442
442
$ class ['ccn ' ] += $ method ['ccn ' ];
443
443
}
444
444
445
445
unset($ method );
446
446
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 ;
450
450
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 ();
453
453
454
454
if ($ class ['executableLines ' ] > 0 && $ class ['coverage ' ] === 100 ) {
455
455
$ this ->numTestedClasses ++;
@@ -459,12 +459,12 @@ private function calculateStatistics(array $classes, array $traits, array $funct
459
459
unset($ class );
460
460
461
461
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 ;
465
465
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 ();
468
468
469
469
if ($ function ['coverage ' ] === 100 ) {
470
470
$ this ->numTestedFunctions ++;
0 commit comments