Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| Cylinder | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| getVolume | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getSurface | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getLateralSurface | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jingga |
| 4 | * |
| 5 | * PHP Version 8.1 |
| 6 | * |
| 7 | * @package phpOMS\Math\Geometry\Shape\D3 |
| 8 | * @copyright Dennis Eichhorn |
| 9 | * @license OMS License 2.0 |
| 10 | * @version 1.0.0 |
| 11 | * @link https://jingga.app |
| 12 | */ |
| 13 | declare(strict_types=1); |
| 14 | |
| 15 | namespace phpOMS\Math\Geometry\Shape\D3; |
| 16 | |
| 17 | /** |
| 18 | * Cylinder shape. |
| 19 | * |
| 20 | * @package phpOMS\Math\Geometry\Shape\D3 |
| 21 | * @license OMS License 2.0 |
| 22 | * @link https://jingga.app |
| 23 | * @since 1.0.0 |
| 24 | */ |
| 25 | final class Cylinder implements D3ShapeInterface |
| 26 | { |
| 27 | /** |
| 28 | * Volume |
| 29 | * |
| 30 | * @param float $r Radius |
| 31 | * @param float $h Height |
| 32 | * |
| 33 | * @return float |
| 34 | * |
| 35 | * @since 1.0.0 |
| 36 | */ |
| 37 | public static function getVolume(float $r, float $h) : float |
| 38 | { |
| 39 | return \M_PI * $r ** 2 * $h; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Surface area |
| 44 | * |
| 45 | * @param float $r Radius |
| 46 | * @param float $h Height |
| 47 | * |
| 48 | * @return float |
| 49 | * |
| 50 | * @since 1.0.0 |
| 51 | */ |
| 52 | public static function getSurface(float $r, float $h) : float |
| 53 | { |
| 54 | return 2 * \M_PI * ($r * $h + $r ** 2); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Lateral surface area |
| 59 | * |
| 60 | * @param float $r Radius |
| 61 | * @param float $h Height |
| 62 | * |
| 63 | * @return float |
| 64 | * |
| 65 | * @since 1.0.0 |
| 66 | */ |
| 67 | public static function getLateralSurface(float $r, float $h) : float |
| 68 | { |
| 69 | return 2 * \M_PI * $r * $h; |
| 70 | } |
| 71 | } |