Skip to content

Commit

Permalink
height in centimeters
Browse files Browse the repository at this point in the history
  • Loading branch information
attogram committed Mar 23, 2019
1 parent 51f2e34 commit 86f0d45
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
21 changes: 14 additions & 7 deletions src/Equation/BasalMetabolicRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public function get(int $equationId = 0, float $bodyFatPercentage = 0.0)
$bodyFatPercentage = (float) $bodyFatPercentage / 100;
}

$heightCentimeters = 0.0;
if ($this->isValidHumanHeight()) {
$heightCentimeters = ($this->human->getHeight() * 100);
}

switch ($equationId) {
case self::KATCH_MCARDLE_2006:
if (!Util::isValidFloat($bodyFatPercentage)) {
Expand Down Expand Up @@ -126,13 +131,13 @@ public function get(int $equationId = 0, float $bodyFatPercentage = 0.0)
switch ($this->human->getSex()) {
case 'm': // Male: (13.397 * Weight_kilograms) + (4.799 * Height_cm) - (5.677 * Age) + 88.362
$bmr = (float) (13.397 * $this->human->getMass())
+ (4.799 * ($this->human->getHeight() / 100))
+ (4.799 * $heightCentimeters)
+ (5.677 * $this->human->getAge())
+ 88.362;
break;
case 'f': // Female: ( 9.247 * Weight_kilograms) + (3.098 * Height_cm) - (4.330 * Age) + 447.593
$bmr = (float) (9.247 * $this->human->getMass())
+ (3.098 * ($this->human->getHeight() / 100))
+ (3.098 * $heightCentimeters)
+ (4.330 * $this->human->getAge())
+ 447.593;
break;
Expand All @@ -145,14 +150,16 @@ public function get(int $equationId = 0, float $bodyFatPercentage = 0.0)
if (!$this->isValidHumanHeight() || !$this->isValidHumanAge() || !$this->isValidHumanSex()) {
return 0.0;
}
// Male: (10 * Weight_kilograms) + (6.25 * Height_cm) - (5 * Age) + 5
// Female: (10 * Weight_kilograms) + (6.25 * Height_cm) - (5 * Age) - 161
$bmr = (10 * $this->human->getMass())
+ (6.25 * ($this->human->getHeight() / 100))
+ (6.25 * $heightCentimeters)
- (5 * $this->human->getAge());
switch ($this->human->getSex()) {
case 'm': // Male: (10 * Weight_kilograms) + (6.25 * Height_cm) - (5 * Age) + 5
case 'm':
$bmr += 5;
break;
case 'f': // Female: (10 * Weight_kilograms) + (6.25 * Height_cm) - (5 * Age) - 161
case 'f':
$bmr -= 161;
break;
default:
Expand All @@ -175,14 +182,14 @@ public function get(int $equationId = 0, float $bodyFatPercentage = 0.0)
switch ($this->human->getSex()) {
case 'm': // Male: (13.7516 * Weight_kilograms) + (5.0033 * Height_cm) - (6.755 * Age) + 66.473
$bmr = (13.7516 * $this->human->getMass())
+ (5.0033 * ($this->human->getHeight() / 100))
+ (5.0033 * $heightCentimeters)
- (6.755 * $this->human->getAge())
+ 66.473;
break;
case 'f': // Female: (9.5634 * Weight_kilograms) + (1.8496 * Height_cm) - (4.6756 * Age) + 655.0955
// BMR = 655.1 + ( 9.563 × weight in kg ) + ( 1.850 × height in cm ) – ( 4.676 × age in years )
$bmr = (9.5634 * $this->human->getMass())
+ (1.8496 * ($this->human->getHeight() / 100))
+ (1.8496 * $heightCentimeters)
- (4.6756 * $this->human->getAge())
+ 655.0955;
break;
Expand Down
7 changes: 4 additions & 3 deletions src/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,10 @@ private function getTableTopic()
. '<br />'
. '<small>'
. '<br /><em>Equations used:</em>'
. "<br />BMI - Body Mass Index: <b>$bmiName</b><br /> &nbsp;&nbsp;&nbsp; <small>$bmiEquation</small>"
. "<br />BFP - Body Fat Percentage: <b>$bfpName</b><br /> &nbsp;&nbsp;&nbsp;<small>$bfpEquation</small>"
. "<br />BMR - Basal Metabolic Rate: <b>$bmrName</b><br /> &nbsp;&nbsp;&nbsp;<small>$bmrEquation</small>"
. "<br />BMI - Body Mass Index&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <b>$bmiName</b>"
. " - BMI = <small>$bmiEquation</small>"
. "<br />BFP - Body Fat Percentage&nbsp;: <b>$bfpName</b> - BFP = <small>$bfpEquation</small>"
. "<br />BMR - Basal Metabolic Rate: <b>$bmrName</b> - BMR = <small>$bmrEquation</small>"
. '</small>'
. '<br />'
. '<br />';
Expand Down

0 comments on commit 86f0d45

Please sign in to comment.