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
Circle
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
 getSurface
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getPerimeter
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRadiusBySurface
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRadiusByPerimeter
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\D2
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\D2;
16
17/**
18 * Circle shape.
19 *
20 * @package phpOMS\Math\Geometry\Shape\D2
21 * @license OMS License 2.0
22 * @link    https://jingga.app
23 * @since   1.0.0
24 */
25final class Circle implements D2ShapeInterface
26{
27    /**
28     * Area
29     *
30     * @param float $r Radius
31     *
32     * @return float
33     *
34     * @since 1.0.0
35     */
36    public static function getSurface(float $r) : float
37    {
38        return \M_PI * $r ** 2;
39    }
40
41    /**
42     * Circumference
43     *
44     * @param float $r Radius
45     *
46     * @return float
47     *
48     * @since 1.0.0
49     */
50    public static function getPerimeter(float $r) : float
51    {
52        return 2 * \M_PI * $r;
53    }
54
55    /**
56     * Radius
57     *
58     * @param float $surface Surface
59     *
60     * @return float
61     *
62     * @since 1.0.0
63     */
64    public static function getRadiusBySurface(float $surface) : float
65    {
66        return \sqrt($surface / \M_PI);
67    }
68
69    /**
70     * Radius
71     *
72     * @param float $C Circumference
73     *
74     * @return float
75     *
76     * @since  1.0.0
77     *
78     * @SuppressWarnings(PHPMD.CamelCaseVariableName)
79     * @SuppressWarnings(PHPMD.CamelCaseParameterName)
80     */
81    public static function getRadiusByPerimeter(float $C) : float
82    {
83        return $C / (2 * \M_PI);
84    }
85}