Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Prism
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 getVolumeRegularLength
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVolumeRegularRadius
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSurfaceRegularLength
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
17use phpOMS\Math\Geometry\Shape\D2\Polygon;
18
19/**
20 * Prism shape.
21 *
22 * @package phpOMS\Math\Geometry\Shape\D3
23 * @license OMS License 2.0
24 * @link    https://jingga.app
25 * @since   1.0.0
26 */
27final class Prism implements D3ShapeInterface
28{
29    /**
30     * Get volume of regular polygon prism by side length
31     *
32     * @param float $length Side length
33     * @param int   $sides  Number of sides
34     * @param float $h      Height
35     *
36     * @return float
37     *
38     * @since 1.0.0
39     */
40    public static function getVolumeRegularLength(float $length, int $sides, float $h) : float
41    {
42        return Polygon::getRegularAreaByLength($length, $sides) * $h;
43    }
44
45    /**
46     * Get volume area of regular polygon prism by radius
47     *
48     * @param float $r     Radius
49     * @param int   $sides Number of sides
50     * @param float $h     Height
51     *
52     * @return float
53     *
54     * @since 1.0.0
55     */
56    public static function getVolumeRegularRadius(float $r, int $sides, float $h) : float
57    {
58        return Polygon::getRegularAreaByRadius($r, $sides) * $h;
59    }
60
61    /**
62     * Get surface area of regular polygon prism by side length
63     *
64     * @param float $length Side length
65     * @param int   $sides  Number of sides
66     * @param float $h      Height
67     *
68     * @return float
69     *
70     * @since 1.0.0
71     */
72    public static function getSurfaceRegularLength(float $length, int $sides, float $h) : float
73    {
74        return Polygon::getRegularAreaByLength($length, $sides) * 2 + $length * $sides * $h;
75    }
76}