Code Coverage
 
Classes and Traits
Functions and Methods
Paths
Branches
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (danger)
50.00%
1 / 2
CRAP
66.67% covered (warning)
66.67%
2 / 3
80.00% covered (warning)
80.00%
4 / 5
100.00% covered (success)
100.00%
4 / 4
PercentCalculator
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
3.33
66.67% covered (warning)
66.67%
2 / 3
80.00% covered (warning)
80.00%
4 / 5
100.00% covered (success)
100.00%
4 / 4
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
 calculatePercent
100.00% covered (success)
100.00%
1 / 1
2.50
50.00% covered (danger)
50.00%
1 / 2
75.00% covered (warning)
75.00%
3 / 4
100.00% covered (success)
100.00%
1 / 1
1<?php
2class PercentCalculator
3{
4    public function __construct(int $numerator, int $denominator)
5    {
6        $this->numerator = $numerator;
7        $this->denominator = $denominator;
8    }
9
10    public function calculatePercent(): float
11    {
12        return $this->denominator ? round($this->numerator / $this->denominator * 100, 1) : 0.0;
13    }
14}