diff --git a/Algorithm/Clustering/AffinityPropagation.php b/Algorithm/Clustering/AffinityPropagation.php index 58a8a93c0..ca601e98a 100644 --- a/Algorithm/Clustering/AffinityPropagation.php +++ b/Algorithm/Clustering/AffinityPropagation.php @@ -28,7 +28,7 @@ final class AffinityPropagation implements ClusteringInterface /** * Points of the cluster centers * - * @var PointInterface[] + * @var Point[] * @since 1.0.0 */ private array $clusterCenters = []; @@ -52,7 +52,7 @@ final class AffinityPropagation implements ClusteringInterface /** * Original points used for clusters * - * @var PointInterface[] + * @var Point[] * @since 1.0.0 */ private array $points = []; @@ -60,7 +60,7 @@ final class AffinityPropagation implements ClusteringInterface /** * Create similarity matrix from points * - * @param PointInterface[] $points Points to create the similarity matrix for + * @param Point[] $points Points to create the similarity matrix for * * @return array> * @@ -103,7 +103,7 @@ final class AffinityPropagation implements ClusteringInterface /** * Generate clusters for points * - * @param PointInterface[] $points Points to cluster + * @param Point[] $points Points to cluster * @param int $iterations Iterations for cluster generation * * @return void @@ -213,7 +213,7 @@ final class AffinityPropagation implements ClusteringInterface /** * {@inheritdoc} */ - public function cluster(PointInterface $point) : ?PointInterface + public function cluster(Point $point) : ?Point { $points = $this->points; $points[] = $point; diff --git a/Algorithm/Clustering/AgglomerativeClustering.php b/Algorithm/Clustering/AgglomerativeClustering.php index dfaaf51e2..3ace0ffaf 100644 --- a/Algorithm/Clustering/AgglomerativeClustering.php +++ b/Algorithm/Clustering/AgglomerativeClustering.php @@ -61,7 +61,7 @@ final class AgglomerativeClustering implements ClusteringInterface */ public function __construct(?\Closure $metric = null, ?\Closure $linkage = null) { - $this->metric = $metric ?? function (PointInterface $a, PointInterface $b) { + $this->metric = $metric ?? function (Point $a, Point $b) { $aCoordinates = $a->coordinates; $bCoordinates = $b->coordinates; @@ -139,7 +139,7 @@ final class AgglomerativeClustering implements ClusteringInterface /** * {@inheritdoc} */ - public function cluster(PointInterface $point) : ?PointInterface + public function cluster(Point $point) : ?Point { return null; } diff --git a/Algorithm/Clustering/Birch.php b/Algorithm/Clustering/Birch.php index 343053fc5..f5d5d6d50 100644 --- a/Algorithm/Clustering/Birch.php +++ b/Algorithm/Clustering/Birch.php @@ -46,7 +46,7 @@ final class Birch implements ClusteringInterface /** * {@inheritdoc} */ - public function cluster(PointInterface $point) : ?PointInterface + public function cluster(Point $point) : ?Point { return null; } diff --git a/Algorithm/Clustering/ClusteringInterface.php b/Algorithm/Clustering/ClusteringInterface.php index c1d31e652..3e882d847 100644 --- a/Algorithm/Clustering/ClusteringInterface.php +++ b/Algorithm/Clustering/ClusteringInterface.php @@ -27,7 +27,7 @@ interface ClusteringInterface /** * Get cluster centroids * - * @return PointInterface[] + * @return Point[] * * @since 1.0.0 */ @@ -36,7 +36,7 @@ interface ClusteringInterface /** * Get cluster assignments of the training data * - * @return PointInterface[] + * @return Point[] * * @since 1.0.0 */ @@ -47,20 +47,20 @@ interface ClusteringInterface * * This point doesn't have to be in the training data. * - * @param PointInterface $point Point to cluster + * @param Point $point Point to cluster * - * @return null|PointInterface + * @return null|Point * * @since 1.0.0 */ - public function cluster(PointInterface $point) : ?PointInterface; + public function cluster(Point $point) : ?Point; /** * Get noise data. * * Data points from the training data that are not part of a cluster. * - * @return PointInterface[] + * @return Point[] * * @since 1.0.0 */ diff --git a/Algorithm/Clustering/DBSCAN.php b/Algorithm/Clustering/DBSCAN.php index 903c3bfd3..dd94bca41 100644 --- a/Algorithm/Clustering/DBSCAN.php +++ b/Algorithm/Clustering/DBSCAN.php @@ -50,7 +50,7 @@ final class DBSCAN implements ClusteringInterface /** * Points outside of any cluster * - * @var PointInterface[] + * @var Point[] * @since 1.0.0 */ private array $noisePoints = []; @@ -58,7 +58,7 @@ final class DBSCAN implements ClusteringInterface /** * All points * - * @var PointInterface[] + * @var Point[] * @since 1.0.0 */ private array $points = []; @@ -66,7 +66,7 @@ final class DBSCAN implements ClusteringInterface /** * Points of the cluster centers * - * @var PointInterface[] + * @var Point[] * @since 1.0.0 */ private array $clusterCenters = []; @@ -76,7 +76,7 @@ final class DBSCAN implements ClusteringInterface * * Array of points assigned to a cluster * - * @var array + * @var array * @since 1.0.0 */ private array $clusters = []; @@ -118,7 +118,7 @@ final class DBSCAN implements ClusteringInterface */ public function __construct(?\Closure $metric = null) { - $this->metric = $metric ?? function (PointInterface $a, PointInterface $b) { + $this->metric = $metric ?? function (Point $a, Point $b) { $aCoordinates = $a->coordinates; $bCoordinates = $b->coordinates; @@ -129,7 +129,7 @@ final class DBSCAN implements ClusteringInterface /** * Expand cluster with additional point and potential neighbors. * - * @param PointInterface $point Point to add to a cluster + * @param Point $point Point to add to a cluster * @param array $neighbors Neighbors of point * @param int $c Cluster id * @param float $epsilon Max distance @@ -140,7 +140,7 @@ final class DBSCAN implements ClusteringInterface * @since 1.0.0 */ private function expandCluster( - PointInterface $point, + Point $point, array $neighbors, int $c, float $epsilon, @@ -174,14 +174,14 @@ final class DBSCAN implements ClusteringInterface /** * Find neighbors of a point * - * @param PointInterface $point Base point for potential neighbors + * @param Point $point Base point for potential neighbors * @param float $epsilon Max distance to neighbor * * @return array * * @since 1.0.0 */ - private function findNeighbors(PointInterface $point, float $epsilon) : array + private function findNeighbors(Point $point, float $epsilon) : array { $neighbors = []; foreach ($this->points as $point2) { @@ -225,7 +225,7 @@ final class DBSCAN implements ClusteringInterface /** * {@inheritdoc} */ - public function cluster(PointInterface $point) : ?PointInterface + public function cluster(Point $point) : ?Point { if ($this->convexHulls === []) { foreach ($this->clusters as $c => $cluster) { @@ -251,7 +251,7 @@ final class DBSCAN implements ClusteringInterface /** * Generate the clusters of the points * - * @param PointInterface[] $points Points to cluster + * @param Point[] $points Points to cluster * @param float $epsilon Max distance * @param int $minPoints Min amount of points required for a cluster * diff --git a/Algorithm/Clustering/DivisiveClustering.php b/Algorithm/Clustering/DivisiveClustering.php index 00d934575..4eac03444 100644 --- a/Algorithm/Clustering/DivisiveClustering.php +++ b/Algorithm/Clustering/DivisiveClustering.php @@ -50,7 +50,7 @@ final class DivisiveClustering implements ClusteringInterface /** * {@inheritdoc} */ - public function cluster(PointInterface $point) : ?PointInterface + public function cluster(Point $point) : ?Point { return null; } diff --git a/Algorithm/Clustering/Kmeans.php b/Algorithm/Clustering/Kmeans.php index 5aa589c1a..902896b76 100755 --- a/Algorithm/Clustering/Kmeans.php +++ b/Algorithm/Clustering/Kmeans.php @@ -46,7 +46,7 @@ final class Kmeans implements ClusteringInterface /** * Points of the cluster centers * - * @var PointInterface[] + * @var Point[] * @since 1.0.0 */ private array $clusterCenters = []; @@ -54,7 +54,7 @@ final class Kmeans implements ClusteringInterface /** * Points of the clusters * - * @var PointInterface[] + * @var Point[] * @since 1.0.0 */ private array $clusters = []; @@ -62,7 +62,7 @@ final class Kmeans implements ClusteringInterface /** * Points * - * @var PointInterface[] + * @var Point[] * @since 1.0.0 */ private array $points = []; @@ -76,7 +76,7 @@ final class Kmeans implements ClusteringInterface */ public function __construct(?\Closure $metric = null) { - $this->metric = $metric ?? function (PointInterface $a, PointInterface $b) { + $this->metric = $metric ?? function (Point $a, Point $b) { $aCoordinates = $a->coordinates; $bCoordinates = $b->coordinates; @@ -87,7 +87,7 @@ final class Kmeans implements ClusteringInterface /** * {@inheritdoc} */ - public function cluster(PointInterface $point) : ?PointInterface + public function cluster(Point $point) : ?Point { $bestCluster = null; $bestDistance = \PHP_FLOAT_MAX; @@ -121,7 +121,7 @@ final class Kmeans implements ClusteringInterface /** * Generate the clusters of the points * - * @param PointInterface[] $points Points to cluster + * @param Point[] $points Points to cluster * @param int<1, max> $clusters Amount of clusters * * @return void @@ -183,14 +183,14 @@ final class Kmeans implements ClusteringInterface /** * Get the index and distance to the nearest cluster center * - * @param PointInterface $point Point to get the cluster for - * @param PointInterface[] $clusterCenters All cluster centers + * @param Point $point Point to get the cluster for + * @param Point[] $clusterCenters All cluster centers * * @return array [index, distance] * * @since 1.0.0 */ - private function nearestClusterCenter(PointInterface $point, array $clusterCenters) : array + private function nearestClusterCenter(Point $point, array $clusterCenters) : array { $index = $point->group; $dist = \PHP_FLOAT_MAX; @@ -208,12 +208,12 @@ final class Kmeans implements ClusteringInterface } /** - * Initializae cluster centers + * Initialize cluster centers * - * @param PointInterface[] $points Points to use for the cluster center initialization + * @param Point[] $points Points to use for the cluster center initialization * @param int<0, max> $n Amount of clusters to use * - * @return PointInterface[] + * @return Point[] * * @since 1.0.0 */ diff --git a/Algorithm/Clustering/MeanShift.php b/Algorithm/Clustering/MeanShift.php index 2c0e7f9b6..d753bb10e 100644 --- a/Algorithm/Clustering/MeanShift.php +++ b/Algorithm/Clustering/MeanShift.php @@ -61,7 +61,7 @@ final class MeanShift implements ClusteringInterface /** * Points outside of any cluster * - * @var PointInterface[] + * @var Point[] * @since 1.0.0 */ private array $noisePoints = []; @@ -79,7 +79,7 @@ final class MeanShift implements ClusteringInterface /** * Points of the cluster centers * - * @var PointInterface[] + * @var Point[] * @since 1.0.0 */ private array $clusterCenters = []; @@ -104,7 +104,7 @@ final class MeanShift implements ClusteringInterface */ public function __construct(?\Closure $metric = null, ?\Closure $kernel = null) { - $this->metric = $metric ?? function (PointInterface $a, PointInterface $b) { + $this->metric = $metric ?? function (Point $a, Point $b) { $aCoordinates = $a->coordinates; $bCoordinates = $b->coordinates; @@ -119,7 +119,7 @@ final class MeanShift implements ClusteringInterface /** * Generate the clusters of the points * - * @param PointInterface[] $points Points to cluster + * @param Point[] $points Points to cluster * @param array $bandwidth Bandwidth(s) * * @return void @@ -170,15 +170,15 @@ final class MeanShift implements ClusteringInterface /** * Perform shift on a point * - * @param PointInterface $point Point to shift - * @param PointInterface $points Array of all points + * @param Point $point Point to shift + * @param Point $points Array of all points * @param array $bandwidth Bandwidth(s) * - * @return PointInterface + * @return Point * * @since 1.0.0 */ - private function shiftPoint(PointInterface $point, array $points, array $bandwidth) : PointInterface + private function shiftPoint(Point $point, array $points, array $bandwidth) : Point { $scaleFactor = 0.0; @@ -209,7 +209,7 @@ final class MeanShift implements ClusteringInterface /** * Group points together into clusters * - * @param PointInterface[] $points Array of points to assign to groups + * @param Point[] $points Array of points to assign to groups * * @return array * @@ -242,14 +242,14 @@ final class MeanShift implements ClusteringInterface /** * Find the closest cluster/group of a point * - * @param PointInterface $point Point to find the cluster for - * @param array $groups Clusters + * @param Point $point Point to find the cluster for + * @param array $groups Clusters * * @return int * * @since 1.0.0 */ - private function findNearestGroup(PointInterface $point, array $groups) : int + private function findNearestGroup(Point $point, array $groups) : int { $nearestGroupIndex = -1; $index = 0; @@ -272,14 +272,14 @@ final class MeanShift implements ClusteringInterface /** * Find distance of point to best cluster/group * - * @param PointInterface $point Point to find the cluster for - * @param PointInterface[] $group Clusters + * @param Point $point Point to find the cluster for + * @param Point[] $group Clusters * * @return float Distance * * @since 1.0.0 */ - private function distanceToGroup(PointInterface $point, array $group) : float + private function distanceToGroup(Point $point, array $group) : float { $minDistance = \PHP_FLOAT_MAX; @@ -305,7 +305,7 @@ final class MeanShift implements ClusteringInterface /** * {@inheritdoc} */ - public function cluster(PointInterface $point) : ?PointInterface + public function cluster(Point $point) : ?Point { $clusterId = $this->findNearestGroup($point, $this->clusters); diff --git a/Algorithm/Clustering/SpectralClustering.php b/Algorithm/Clustering/SpectralClustering.php index 1ed6f6307..d0a4d5475 100644 --- a/Algorithm/Clustering/SpectralClustering.php +++ b/Algorithm/Clustering/SpectralClustering.php @@ -46,7 +46,7 @@ final class SpectralClustering implements ClusteringInterface /** * {@inheritdoc} */ - public function cluster(PointInterface $point) : ?PointInterface + public function cluster(Point $point) : ?Point { return null; } diff --git a/Algorithm/Rating/TrueSkill.php b/Algorithm/Rating/TrueSkill.php index 396840e9f..7356916c9 100644 --- a/Algorithm/Rating/TrueSkill.php +++ b/Algorithm/Rating/TrueSkill.php @@ -28,6 +28,7 @@ use phpOMS\Math\Stochastic\Distribution\NormalDistribution; * @todo Implement https://github.com/sublee/trueskill/blob/master/trueskill/__init__.py * https://github.com/Karaka-Management/phpOMS/issues/337 */ +// phpcs:ignoreFile class TrueSkill { public const DEFAULT_MU = 25; diff --git a/Business/Finance/Loan.php b/Business/Finance/Loan.php index 79421b9a0..459a1848c 100755 --- a/Business/Finance/Loan.php +++ b/Business/Finance/Loan.php @@ -134,16 +134,49 @@ final class Loan return $loan / $collateral; } + /** + * Calculate the payment for amortization loans (interest + principal) + * + * @param float $loan Loan amount + * @param float $r Rate + * @param float $duration Loan duration + * @param float $interval Payment interval + * + * @return float + * + * @since 1.0.0 + */ public static function getAmortizationLoanPayment(float $loan, float $r, int $duration, int $interval) : float { return $loan * (($r / $interval * (1.0 + $r / $interval) / $duration) / ((1.0 + $r / $interval) / $duration) - 1); } + /** + * Calculate the interest for amortization loans + * + * @param float $loan Loan amount + * @param float $r Rate + * @param float $interval Payment interval + * + * @return float + * + * @since 1.0.0 + */ public static function getAmortizationLoanInterest(float $loan, float $r, int $interval) : float { return $loan * $r / $interval; } + /** + * Calculate the principal for amortization loans + * + * @param float $payment Total payment + * @param float $interval Payment interval + * + * @return float + * + * @since 1.0.0 + */ public static function getAmortizationPrincipalPayment(float $payment, float $interest) : float { return $payment - $interest; diff --git a/DataStorage/Database/Mapper/ReadMapper.php b/DataStorage/Database/Mapper/ReadMapper.php index 1b5a1cd3a..35fd31247 100755 --- a/DataStorage/Database/Mapper/ReadMapper.php +++ b/DataStorage/Database/Mapper/ReadMapper.php @@ -1327,6 +1327,17 @@ final class ReadMapper extends DataMapperAbstract } } + /** + * Paginate results + * + * @param string $member Member to use for pagination + * @param null|string $ptype Pagination type (previous/next) + * @param mixed $offset Offset + * + * @return self + * + * @since 1.0.0 + */ public function paginate(string $member, ?string $ptype, mixed $offset) : self { if ($ptype === 'p') { diff --git a/Message/Http/HttpRequest.php b/Message/Http/HttpRequest.php index 593db590f..11614d31e 100755 --- a/Message/Http/HttpRequest.php +++ b/Message/Http/HttpRequest.php @@ -21,7 +21,6 @@ use phpOMS\Message\RequestAbstract; use phpOMS\Router\RouteVerb; use phpOMS\Security\Guard; use phpOMS\Uri\HttpUri; -use phpOMS\Uri\UriInterface; /** * Request class. @@ -73,12 +72,12 @@ final class HttpRequest extends RequestAbstract /** * Constructor. * - * @param UriInterface $uri Uri + * @param HttpUri $uri Uri * @param Localization $l11n Localization * * @since 1.0.0 */ - public function __construct(?UriInterface $uri = null, ?Localization $l11n = null) + public function __construct(?HttpUri $uri = null, ?Localization $l11n = null) { $this->header = new HttpHeader(); $this->header->l11n = $l11n ?? new Localization(); @@ -455,13 +454,13 @@ final class HttpRequest extends RequestAbstract /** * Set request uri. * - * @param UriInterface $uri Uri + * @param HttpUri $uri Uri * * @return void * * @since 1.0.0 */ - public function setUri(UriInterface $uri) : void + public function setUri(HttpUri $uri) : void { $this->uri = $uri; $this->data += $uri->getQueryArray(); diff --git a/Router/SocketRouter.php b/Router/SocketRouter.php index a150343a5..7c070924d 100755 --- a/Router/SocketRouter.php +++ b/Router/SocketRouter.php @@ -29,7 +29,7 @@ final class SocketRouter implements RouterInterface /** * Routes. * - * @var array> + * @var array> * @since 1.0.0 */ private array $routes = []; diff --git a/Router/WebRouter.php b/Router/WebRouter.php index e39256a97..a3658d619 100755 --- a/Router/WebRouter.php +++ b/Router/WebRouter.php @@ -40,7 +40,7 @@ final class WebRouter implements RouterInterface /** * Routes. * - * @var array> + * @var array> * @since 1.0.0 */ private array $routes = []; diff --git a/Utils/Barcode/BarAbstract.php b/Utils/Barcode/BarAbstract.php index e6aa62f29..13a085411 100755 --- a/Utils/Barcode/BarAbstract.php +++ b/Utils/Barcode/BarAbstract.php @@ -70,7 +70,7 @@ abstract class BarAbstract extends CodeAbstract /** * {@inheritdoc} */ - public function get() : mixed + public function get() : ?\GdImage { $codeString = static::$CODE_START . $this->generateCodeString() . static::$CODE_END; @@ -137,7 +137,7 @@ abstract class BarAbstract extends CodeAbstract * * @since 1.0.0 */ - protected function createImage(string $codeString) : mixed + protected function createImage(string $codeString) : \GdImage { $dimensions = $this->calculateDimensions($codeString); $image = \imagecreate($dimensions['width'], $dimensions['height']); diff --git a/Utils/Barcode/CodeAbstract.php b/Utils/Barcode/CodeAbstract.php index 40fe492df..2782b6753 100755 --- a/Utils/Barcode/CodeAbstract.php +++ b/Utils/Barcode/CodeAbstract.php @@ -242,9 +242,9 @@ abstract class CodeAbstract /** * Get image reference * - * @return \GdImage + * @return null|\GdImage * * @since 1.0.0 */ - abstract public function get() : mixed; + abstract public function get() : ?\GdImage; } diff --git a/Utils/Barcode/TwoDAbstract.php b/Utils/Barcode/TwoDAbstract.php index 130844189..3e5a96abe 100755 --- a/Utils/Barcode/TwoDAbstract.php +++ b/Utils/Barcode/TwoDAbstract.php @@ -28,7 +28,7 @@ abstract class TwoDAbstract extends CodeAbstract /** * {@inheritdoc} */ - public function get() : mixed + public function get() : ?\GdImage { $codeArray = $this->generateCodeArray();