orioledev/otus-body-mass-index-calculator

1.0.2 2025-02-16 10:40 UTC

This package is auto-updated.

Last update: 2025-03-16 10:54:49 UTC


README

Calculation of body mass index based on a person's given weight and height.

Installation

The package could be installed with Composer:

composer require orioledev/otus-body-mass-index-calculator

Usage

<?php

use OrioleDev\OtusBodyMassIndexCalculator\Calculator;

$weight = 60.5; // Weight in kilograms
$height = 170;  // Height in centimeters

$calc = new Calculator();

try {
    echo 'Ваш индекс массы тела: ' . $calc->calculate($weight, $height) . PHP_EOL;   // 20.9
    echo 'Комментарий: ' . $calc->getInfo($weight, $height) . PHP_EOL;               // Здоровый вес
} catch (RuntimeException $e) {
    echo 'Ошибка: ' . $e->getMessage();
}