Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
Cone
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 getVolume
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSurface
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSlantHeight
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHeightFromVolume
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
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 */
13declare(strict_types=1);
14
15namespace phpOMS\Math\Geometry\Shape\D3;
16
17/**
18 * Cone 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 */
25final class Cone 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 / 3;
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 \M_PI * $r * ($r + \sqrt($h ** 2 + $r ** 2));
55    }
56
57    /**
58     * Slant height
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 getSlantHeight(float $r, float $h) : float
68    {
69        return \sqrt($h ** 2 + $r ** 2);
70    }
71
72    /**
73     * Height
74     *
75     * @param float $V Volume
76     * @param float $r Radius
77     *
78     * @return float
79     *
80     * @since  1.0.0
81     *
82     * @SuppressWarnings(PHPMD.CamelCaseVariableName)
83     * @SuppressWarnings(PHPMD.CamelCaseParameterName)
84     */
85    public static function getHeightFromVolume(float $V, float $r) : float
86    {
87        return 3 * $V / (\M_PI * $r ** 2);
88    }
89}