Skip to content

Commit

Permalink
Basal Metabolic Rate equations
Browse files Browse the repository at this point in the history
  • Loading branch information
attogram committed Mar 23, 2019
1 parent 7ceb26e commit 51f2e34
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 46 deletions.
12 changes: 4 additions & 8 deletions src/AverageHuman.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Attogram\Body;

use Attogram\Body\Equation\BasalMetabolicRate;
use Attogram\Body\Equation\BodyFatPercentage;
use Attogram\Body\Equation\BodyMassIndex;

Expand Down Expand Up @@ -51,8 +52,6 @@ public function getBodyFatPercentage(int $equation)
}

/**
* Get Lean Body Mass
*
* @return float
*/
public function getLeanBodyMass()
Expand All @@ -69,15 +68,12 @@ public function getLeanBodyMass()
*
* Katch-McArdle Formula: BMR = 370 + (21.6 * (WeightInKilograms * (1 - BodyFatPercentage)))
*
* @param int $equation
* @return float
*/
public function getBMR()
public function getBasalMetabolicRate(int $equation)
{
if (!Util::isValidFloat($this->bfp) || !Util::isValidFloat($this->mass)) {
return $this->bmr = 0.0;
}

return $this->bmr = (float) 370 + (21.6 * ($this->mass * (1 - ($this->bfp / 100))));
return $this->bmr = (new BasalMetabolicRate($this))->get($equation, $this->bfp);
}

/**
Expand Down
197 changes: 160 additions & 37 deletions src/Equation/BasalMetabolicRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,74 @@

namespace Attogram\Body\Equation;

use Attogram\Body\Util;

/**
* Class BasalMetabolicRate
* @package Attogram\Body\Equation
*/
class BasalMetabolicRate extends Equation
{
const KATCH_MCARDLE_2006 = 1;
const KATCH_MCARDLE_HYBRID_20XX = 2;
const KATCH_MCARDLE_2006 = 1;
const KATCH_MCARDLE_HYBRID_20XX = 2;
const HARRIS_BENEDICT_REVISED_1984 = 3;
const MIFFLIN_ST_JEOR_1990 = 4;
const CUNNINGHAM_1980 = 5;
const HARRIS_BENEDICT_1919 = 6;
const MIFFLIN_ST_JEOR_1990 = 4;
const CUNNINGHAM_1980 = 5;
const HARRIS_BENEDICT_1919 = 6;

protected static $equations = [
self::KATCH_MCARDLE_2006 => [
'name' => 'Katch-McArdle 2006',
'metric' => '370 + (21.6 * (Weight_kilograms * (1 - BFP)))',
'name' => 'Katch-McArdle 2006',
'metric' => '370 + (21.6 * (Weight_kilograms * (1 - BFP)))',
'imperial' => '',
'cite' => 'McArdle W (2006). Essentials of exercise physiology.'
. ' Lippincott Williams & Wilkins. p. 266. ISBN 9780495014836.',
'cite' => 'McArdle W (2006). Essentials of exercise physiology.'
. ' Lippincott Williams & Wilkins. p. 266. ISBN 9780495014836.',
],
self::KATCH_MCARDLE_HYBRID_20XX => [
'name' => 'Katch-McArdle-Hybrid 20XX',
'metric' => '(370 * (1 - BFP)) + (21.6 * (Weight_kilograms * (1 - BFP)))'
. ' + (6.17 * (Weight_kilograms * BFP))',
'name' => 'Katch-McArdle-Hybrid 20XX',
'metric' => '(370 * (1 - BFP)) + (21.6 * (Weight_kilograms * (1 - BFP)))'
. ' + (6.17 * (Weight_kilograms * BFP))',
'imperial' => '',
'cite' => '<https://www.sailrabbit.com/bmr/>',
'cite' => '<https://www.sailrabbit.com/bmr/>',
],
self::HARRIS_BENEDICT_REVISED_1984 => [
'name' => 'Harris-Benedict-Revised 1984',
'metric' => 'Male: (13.397 * Weight_kilograms) + (4.799 * Height_cm) - (5.677 * Age) + 88.362'
. "\n\t"
. 'Female: (9.247 * Weight_kilograms) + (3.098 * Height_cm) - (4.330 * Age) + 447.593',
'name' => 'Harris-Benedict-Revised 1984',
'metric' => 'Male: (13.397 * Weight_kilograms) + (4.799 * Height_cm) - (5.677 * Age) + 88.362'
. "\n\t"
. 'Female: (9.247 * Weight_kilograms) + (3.098 * Height_cm) - (4.330 * Age) + 447.593',
'imperial' => '',
'cite' => 'Roza AM, Shizgal HM (1984).'
'cite' => 'Roza AM, Shizgal HM (1984).'
. ' "The Harris Benedict equation reevaluated: resting energy requirements and the body cell mass".'
. ' The American Journal of Clinical Nutrition. 40 (1): 168–82. PMID 6741850.'
. ' <https://www.ncbi.nlm.nih.gov/pubmed/6741850>',
],
self::MIFFLIN_ST_JEOR_1990 => [
'name' => 'Mifflin-St Jeor 1990',
'metric' => 'Male: (10 * Weight_kg) + (6.25 * Height_cm) - (5 * Age) + 5'
. "\n\t"
. 'Female: (10 * Weight_kg) + (6.25 * Height_cm) - (5 * Age) - 161',
'name' => 'Mifflin-St Jeor 1990',
'metric' => 'Male: (10 * Weight_kilograms) + (6.25 * Height_cm) - (5 * Age) + 5'
. "\n\t"
. 'Female: (10 * Weight_kilograms) + (6.25 * Height_cm) - (5 * Age) - 161',
'imperial' => '',
'cite' => 'Mifflin MD, St Jeor ST, Hill LA, Scott BJ, Daugherty SA, Koh YO (1990).'
. ' "A new predictive equation for resting energy expenditure in healthy individuals".'
. ' The American Journal of Clinical Nutrition. 51 (2): 241–7. PMID 2305711.'
. ' <https://www.ncbi.nlm.nih.gov/pubmed/2305711>',
'cite' => 'Mifflin MD, St Jeor ST, Hill LA, Scott BJ, Daugherty SA, Koh YO (1990).'
. ' "A new predictive equation for resting energy expenditure in healthy individuals".'
. ' The American Journal of Clinical Nutrition. 51 (2): 241–7. PMID 2305711.'
. ' <https://www.ncbi.nlm.nih.gov/pubmed/2305711>',
],
self::CUNNINGHAM_1980 => [
'name' => 'Cunningham 1980',
'metric' => '500 + (22 * (Weight_kg * (1 - BFP)))',
'name' => 'Cunningham 1980',
'metric' => '500 + (22 * (Weight_kilograms * (1 - BFP)))',
'imperial' => '',
'cite' => 'Cunningham JJ.'
. ' A reanalysis of the factors influencing basal metabolic rate in normal adults.'
. ' The American Journal of Clinical Nutrition 1980; 33: 2372-4.'
. ' <https://www.ncbi.nlm.nih.gov/pubmed/7435418>',
'cite' => 'Cunningham JJ.'
. ' A reanalysis of the factors influencing basal metabolic rate in normal adults.'
. ' The American Journal of Clinical Nutrition 1980; 33: 2372-4.'
. ' <https://www.ncbi.nlm.nih.gov/pubmed/7435418>',
],
self::HARRIS_BENEDICT_1919 => [
'name' => 'Harris-Benedict 1919',
'metric' => 'Male: (13.7516 * Weight_kg) + (5.0033 * Height_cm) - (6.755 * Age) + 66.473'
. "\n\t"
. 'Female: (9.5634 * Weight_kg) + (1.8496 * Height_cm) - (4.6756 * Age) + 655.0955',
'name' => 'Harris-Benedict 1919',
'metric' => 'Male: (13.7516 * Weight_kilograms) + (5.0033 * Height_cm) - (6.755 * Age) + 66.473'
. "\n\t"
. 'Female: (9.5634 * Weight_kilograms) + (1.8496 * Height_cm) - (4.6756 * Age) + 655.0955',
'imperial' => '',
'cite' => 'Harris JA, Benedict FG (1918). "A Biometric Study of Human Basal Metabolism".'
'cite' => 'Harris JA, Benedict FG (1918). "A Biometric Study of Human Basal Metabolism".'
. ' Proceedings of the National Academy of Sciences of the United States of America. 4 (12): 370–3.'
. ' doi:10.1073/pnas.4.12.370. PMC 1091498. PMID 16576330.'
. ' <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1091498/>'
Expand All @@ -78,4 +80,125 @@ class BasalMetabolicRate extends Equation
. ' <https://archive.org/details/biometricstudyof00harruoft/page/98>',
],
];

/**
* Get Basal Metabolic Rate
*
* @param int $equationId
* @param float $bodyFatPercentage
* @return float
*/
public function get(int $equationId = 0, float $bodyFatPercentage = 0.0)
{
if (!$this->isValidHumanMass()) {
return 0.0;
}

if ($bodyFatPercentage) {
$bodyFatPercentage = (float) $bodyFatPercentage / 100;
}

switch ($equationId) {
case self::KATCH_MCARDLE_2006:
if (!Util::isValidFloat($bodyFatPercentage)) {
return 0.0;
}
// 370 + (21.6 * (Weight_kilograms * (1 - BFP)))
$bmr = 370 + (21.6 * ($this->human->getMass() * (1 - $bodyFatPercentage)));
break;

case self::KATCH_MCARDLE_HYBRID_20XX:
if (!Util::isValidFloat($bodyFatPercentage)) {
return 0.0;
}
// (370 * (1 - BFP)) + (21.6 * (Weight_kilograms * (1 - BFP))) + (6.17 * (Weight_kilograms * BFP))
$bmr = (float) (
(370 * (1 - $bodyFatPercentage))
+ (21.6 * ($this->human->getMass() * (1 - $bodyFatPercentage)))
+ (6.17 * ($this->human->getMass() * $bodyFatPercentage))
);
break;

case self::HARRIS_BENEDICT_REVISED_1984:
if (!$this->isValidHumanHeight() || !$this->isValidHumanAge() || !$this->isValidHumanSex()) {
return 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))
+ (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))
+ (4.330 * $this->human->getAge())
+ 447.593;
break;
default:
return 0.0;
}
break;

case self::MIFFLIN_ST_JEOR_1990:
if (!$this->isValidHumanHeight() || !$this->isValidHumanAge() || !$this->isValidHumanSex()) {
return 0.0;
}
$bmr = (10 * $this->human->getMass())
+ (6.25 * ($this->human->getHeight() / 100))
- (5 * $this->human->getAge());
switch ($this->human->getSex()) {
case 'm': // Male: (10 * Weight_kilograms) + (6.25 * Height_cm) - (5 * Age) + 5
$bmr += 5;
break;
case 'f': // Female: (10 * Weight_kilograms) + (6.25 * Height_cm) - (5 * Age) - 161
$bmr -= 161;
break;
default:
return 0.0;
}
break;

case self::CUNNINGHAM_1980:
if (!Util::isValidFloat($bodyFatPercentage)) {
return 0.0;
}
// 500 + (22 * (Weight_kilograms * (1 - BFP)))
$bmr = (float) 500 + (22 * ($this->human->getMass() * (1 - $bodyFatPercentage)));
break;

case self::HARRIS_BENEDICT_1919:
if (!$this->isValidHumanHeight() || !$this->isValidHumanAge() || !$this->isValidHumanSex()) {
return 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))
- (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))
- (4.6756 * $this->human->getAge())
+ 655.0955;
break;
default:
return 0.0;
}
break;

default:
return 0.0;
}

if ($bmr < 0) {
return 0.0;
}

return $bmr;
}
}
7 changes: 6 additions & 1 deletion src/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ private function setInfo()
$this->info["$mass"]['leanMass']
= number_format($this->human->getLeanBodyMass(), 2);
$this->info["$mass"]['bmr']
= number_format($this->human->getBMR(), 0, '', '');
= number_format(
$this->human->getBasalMetabolicRate($this->config->equationBasalMetabolicRate),
0,
'',
''
);
$this->info["$mass"]['tdeeSedentary']
= number_format($this->human->getTDEE(PhysicalActivityLevel::SEDENTARY), 0, '', '');
$this->info["$mass"]['tdeeLight']
Expand Down

0 comments on commit 51f2e34

Please sign in to comment.