mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
Fixing tests and documentation
This commit is contained in:
parent
3ec9c8c1bb
commit
6b6021d25f
|
|
@ -63,9 +63,15 @@ class EventManager implements Mediator
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attach(string $group, \Closure $callback, bool $remove = false)
|
||||
public function attach(string $group, \Closure $callback, bool $remove = false) : bool
|
||||
{
|
||||
if(isset($this->callbacks[$group])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->callbacks[$group] = ['remove' => $remove, 'func' => $callback];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -87,7 +93,7 @@ class EventManager implements Mediator
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function trigger(string $id, string $group)
|
||||
public function trigger(string $group, string $id = 0)
|
||||
{
|
||||
if(isset($this->groups[$group])) {
|
||||
unset($this->groups[$group][$id]);
|
||||
|
|
@ -113,7 +119,7 @@ class EventManager implements Mediator
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addGroup(string $id, string $group)
|
||||
public function addGroup(string $group, $id)
|
||||
{
|
||||
if(!isset($this->groups[$group])) {
|
||||
$this->groups[$group] = [];
|
||||
|
|
|
|||
|
|
@ -145,14 +145,14 @@ class Integer
|
|||
* @param int $value Integer to factorize
|
||||
* @param int $limit Max amount of iterations
|
||||
*
|
||||
* @return int
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn
|
||||
*/
|
||||
public static function fermatFactor(int $value, int $limit = 1000000) : int
|
||||
public static function fermatFactor(int $value, int $limit = 1000000) : array
|
||||
{
|
||||
if (($value % 2) !== 0) {
|
||||
throw new \Exception('Only odd integers are allowed');
|
||||
|
|
@ -167,6 +167,6 @@ class Integer
|
|||
$b2 = $a * $a - $value;
|
||||
}
|
||||
|
||||
return (int) round($a - sqrt($b2));
|
||||
return [(int) round($a - sqrt($b2)), (int) round($a + sqrt($b2))];
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ class Circle implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getSurface(float $r)
|
||||
public static function getSurface(float $r) : float
|
||||
{
|
||||
return pi() * $r ** 2;
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ class Circle implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getPerimeter(float $r)
|
||||
public static function getPerimeter(float $r) : float
|
||||
{
|
||||
return 2 * pi() * $r;
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ class Circle implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getRadiusBySurface(float $surface)
|
||||
public static function getRadiusBySurface(float $surface) : float
|
||||
{
|
||||
return sqrt($surface / pi());
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ class Circle implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getRadiusByPerimeter(float $C)
|
||||
public static function getRadiusByPerimeter(float $C) : float
|
||||
{
|
||||
return $C / (2 * pi());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Rectangle implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getSurface(float $a, float $b)
|
||||
public static function getSurface(float $a, float $b) : float
|
||||
{
|
||||
return $a * $b;
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ class Rectangle implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getPerimeter(float $a, float $b)
|
||||
public static function getPerimeter(float $a, float $b) : float
|
||||
{
|
||||
return 2 * ($a + $b);
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ class Rectangle implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getDiagonal(float $a, float $b)
|
||||
public static function getDiagonal(float $a, float $b) : float
|
||||
{
|
||||
return sqrt($a * $a + $b * $b);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class Trapezoid implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getSurface(float $a, float $b, float $h)
|
||||
public static function getSurface(float $a, float $b, float $h) : float
|
||||
{
|
||||
return ($a + $b) / 2 * $h;
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ class Trapezoid implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getPerimeter(float $a, float $b, float $c, float $d)
|
||||
public static function getPerimeter(float $a, float $b, float $c, float $d) : float
|
||||
{
|
||||
return $a + $b + $c + $d;
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ class Trapezoid implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getHeight(float $area, float $a, float $b)
|
||||
public static function getHeight(float $area, float $a, float $b) : float
|
||||
{
|
||||
return 2 * $area / ($a + $b);
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ class Trapezoid implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getA(float $area, float $h, float $b)
|
||||
public static function getA(float $area, float $h, float $b) : float
|
||||
{
|
||||
return 2 * $area / $h - $b;
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ class Trapezoid implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getB(float $area, float $h, float $a)
|
||||
public static function getB(float $area, float $h, float $a) : float
|
||||
{
|
||||
return 2 * $area / $h - $a;
|
||||
}
|
||||
|
|
@ -164,7 +164,7 @@ class Trapezoid implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getC(float $perimeter, float $a, float $b, float $d)
|
||||
public static function getC(float $perimeter, float $a, float $b, float $d) : float
|
||||
{
|
||||
return $perimeter - $a - $b - $d;
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ class Trapezoid implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getD(float $perimeter, float $a, float $b, float $c)
|
||||
public static function getD(float $perimeter, float $a, float $b, float $c) : float
|
||||
{
|
||||
return $perimeter - $a - $b - $c;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class Triangle implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getSurface(float $b, float $h)
|
||||
public static function getSurface(float $b, float $h) : float
|
||||
{
|
||||
return $h * $b / 2;
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ class Triangle implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getPerimeter(float $a, float $b, float $c)
|
||||
public static function getPerimeter(float $a, float $b, float $c) : float
|
||||
{
|
||||
return $a + $b + $c;
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ class Triangle implements D2ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getHeight(float $area, float $b)
|
||||
public static function getHeight(float $area, float $b) : float
|
||||
{
|
||||
return 2 * $area / $b;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Cone implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getVolume(float $r, float $h)
|
||||
public static function getVolume(float $r, float $h) : float
|
||||
{
|
||||
return pi() * $r ** 2 * $h / 3;
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ class Cone implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getSurface(float $r, float $h)
|
||||
public static function getSurface(float $r, float $h) : float
|
||||
{
|
||||
return pi() * $r * ($r + sqrt($h ** 2 + $r ** 2));
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ class Cone implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getSlantHeight(float $r, float $h)
|
||||
public static function getSlantHeight(float $r, float $h) : float
|
||||
{
|
||||
return sqrt($h ** 2 + $r ** 2);
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ class Cone implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getHeight(float $V, float $r)
|
||||
public static function getHeight(float $V, float $r) : float
|
||||
{
|
||||
return 4 * $V / (pi() * $r ** 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Cuboid implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getVolume(float $a, float $b, float $h)
|
||||
public static function getVolume(float $a, float $b, float $h) : float
|
||||
{
|
||||
return $a * $b * $h;
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ class Cuboid implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getSurface(float $a, float $b, float $h)
|
||||
public static function getSurface(float $a, float $b, float $h) : float
|
||||
{
|
||||
return 2 * ($a * $b + $a * $h + $b * $h);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Cylinder implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getVolume(float $r, float $h)
|
||||
public static function getVolume(float $r, float $h) : float
|
||||
{
|
||||
return pi() * $r ** 2 * $h;
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ class Cylinder implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getSurface(float $r, float $h)
|
||||
public static function getSurface(float $r, float $h) : float
|
||||
{
|
||||
return 2 * pi() * ($r * $h + $r ** 2);
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ class Cylinder implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getLateralSurface(float $r, float $h)
|
||||
public static function getLateralSurface(float $r, float $h) : float
|
||||
{
|
||||
return 2 * pi() * $r * $h;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class RectangularPyramid implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getVolume(float $a, float $b, float $h)
|
||||
public static function getVolume(float $a, float $b, float $h) : float
|
||||
{
|
||||
return $a * $b * $h / 3;
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ class RectangularPyramid implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getSurface(float $a, float $b, float $h)
|
||||
public static function getSurface(float $a, float $b, float $h) : float
|
||||
{
|
||||
return $a * $b + $a * sqrt(($b / 2) ** 2 + $h ** 2) + $b * sqrt(($a / 2) ** 2 + $h ** 2);
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ class RectangularPyramid implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getLateralSurface(float $a, float $b, float $h)
|
||||
public static function getLateralSurface(float $a, float $b, float $h) : float
|
||||
{
|
||||
return $a * sqrt(($b / 2) ** 2 + $h ** 2) + $b * sqrt(($a / 2) ** 2 + $h ** 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class Tetrahedron implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getVolume(float $a)
|
||||
public static function getVolume(float $a) : float
|
||||
{
|
||||
return $a ** 3 / (6 * sqrt(2));
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ class Tetrahedron implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getSurface(float $a)
|
||||
public static function getSurface(float $a) : float
|
||||
{
|
||||
return sqrt(3) * $a ** 2;
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ class Tetrahedron implements D3ShapeInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getFaceArea(float $a)
|
||||
public static function getFaceArea(float $a) : float
|
||||
{
|
||||
return sqrt(3) / 4 * $a ** 2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,28 +62,28 @@ interface Mediator extends \Countable
|
|||
*
|
||||
* Add new element to group
|
||||
*
|
||||
* @param string $id Event ID
|
||||
* @param string $group Group
|
||||
* @param string $id Event ID
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function addGroup(string $id, string $group);
|
||||
public function addGroup(string $group, string $id);
|
||||
|
||||
/**
|
||||
* Trigger event.
|
||||
*
|
||||
* An object fires an event
|
||||
*
|
||||
* @param string $id Event ID
|
||||
* @param string $group Group
|
||||
* @param string $id Event ID
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function trigger(string $id, string $group);
|
||||
public function trigger(string $group, string $id);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user