mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
improve baseline
This commit is contained in:
parent
fb968fbef7
commit
3aed840c77
|
|
@ -52,7 +52,7 @@ class Backpack implements BackpackInterface
|
|||
/**
|
||||
* Items inside the backpack
|
||||
*
|
||||
* @var ItemInterface[]
|
||||
* @var array<int, array{item:ItemInterface, quantity:int|float}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $items = [];
|
||||
|
|
|
|||
|
|
@ -952,7 +952,7 @@ final class FinanceFormulas
|
|||
*
|
||||
* Also known as compounded annual growth rate.
|
||||
*
|
||||
* @param array<float|int> $r Rate of return
|
||||
* @param array<int|float> $r Rate of return
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -1080,7 +1080,7 @@ final class FinanceFormulas
|
|||
/**
|
||||
* Net Present Value
|
||||
*
|
||||
* @param array<float|int> $C Cash flow ($C[0] = initial investment)
|
||||
* @param array<int|float> $C Cash flow ($C[0] = initial investment)
|
||||
* @param float $r Discount rate
|
||||
*
|
||||
* @return float
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ final class Lorenzkurve
|
|||
/**
|
||||
* Calculate Gini coefficient
|
||||
*
|
||||
* @param array<float|int> $data Datapoints (can be unsorted)
|
||||
* @param array<int|float> $data Datapoints (can be unsorted)
|
||||
*
|
||||
* @return float Returns the gini coefficient
|
||||
*
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ final class StockBonds
|
|||
/**
|
||||
* Holding Period Return
|
||||
*
|
||||
* @param array<float|int> $r Rate of return
|
||||
* @param array<int|float> $r Rate of return
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ final class Money implements \Serializable
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param float|int|string $value Value
|
||||
* @param int|float|string $value Value
|
||||
* @param string $thousands Thousands separator
|
||||
* @param string $decimal Decimal separator
|
||||
* @param string $symbol Currency symbol
|
||||
|
|
@ -208,7 +208,7 @@ final class Money implements \Serializable
|
|||
/**
|
||||
* Add money.
|
||||
*
|
||||
* @param float|int|Money|string $value Value to add
|
||||
* @param int|float|Money|string $value Value to add
|
||||
*
|
||||
* @return Money
|
||||
*
|
||||
|
|
@ -242,7 +242,7 @@ final class Money implements \Serializable
|
|||
/**
|
||||
* Sub money.
|
||||
*
|
||||
* @param float|int|Money|string $value Value to subtract
|
||||
* @param int|float|Money|string $value Value to subtract
|
||||
*
|
||||
* @return Money
|
||||
*
|
||||
|
|
@ -264,7 +264,7 @@ final class Money implements \Serializable
|
|||
/**
|
||||
* Mult.
|
||||
*
|
||||
* @param float|int $value Value to multiply with
|
||||
* @param int|float $value Value to multiply with
|
||||
*
|
||||
* @return Money
|
||||
*
|
||||
|
|
@ -282,7 +282,7 @@ final class Money implements \Serializable
|
|||
/**
|
||||
* Div.
|
||||
*
|
||||
* @param float|int $value Value to divide by
|
||||
* @param int|float $value Value to divide by
|
||||
*
|
||||
* @return Money
|
||||
*
|
||||
|
|
@ -314,7 +314,7 @@ final class Money implements \Serializable
|
|||
/**
|
||||
* Power.
|
||||
*
|
||||
* @param float|int $value Value to power
|
||||
* @param int|float $value Value to power
|
||||
*
|
||||
* @return Money
|
||||
*
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ final class MonotoneChain
|
|||
/**
|
||||
* Create convex hull
|
||||
*
|
||||
* @param array<int, array{x:float|int, y:float|int}> $points Points (Point Cloud)
|
||||
* @param array<int, array{x:int|float, y:int|float}> $points Points (Point Cloud)
|
||||
*
|
||||
* @return array<int, array{x:float|int, y:float|int}>
|
||||
* @return array<int, array{x:int|float, y:int|float}>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -80,9 +80,9 @@ final class MonotoneChain
|
|||
/**
|
||||
* Counter clock wise turn?
|
||||
*
|
||||
* @param array{x:float|int, y:float|int} $a Point a
|
||||
* @param array{x:float|int, y:float|int} $b Point b
|
||||
* @param array{x:float|int, y:float|int} $c Point c
|
||||
* @param array{x:int|float, y:int|float} $a Point a
|
||||
* @param array{x:int|float, y:int|float} $b Point b
|
||||
* @param array{x:int|float, y:int|float} $c Point c
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -96,8 +96,8 @@ final class MonotoneChain
|
|||
/**
|
||||
* Sort by x coordinate then by z coordinate
|
||||
*
|
||||
* @param array{x:float|int, y:float|int} $a Point a
|
||||
* @param array{x:float|int, y:float|int} $b Point b
|
||||
* @param array{x:int|float, y:int|float} $a Point a
|
||||
* @param array{x:int|float, y:int|float} $b Point b
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
|
|||
|
|
@ -79,9 +79,9 @@ class Matrix implements \ArrayAccess, \Iterator
|
|||
/**
|
||||
* Set value.
|
||||
*
|
||||
* @param int $m Row
|
||||
* @param int $n Column
|
||||
* @param int $value Value
|
||||
* @param int $m Row
|
||||
* @param int $n Column
|
||||
* @param int|float $value Value
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -336,7 +336,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
|||
/**
|
||||
* Set matrix array.
|
||||
*
|
||||
* @param array<int, array<float|int>> $matrix Matrix
|
||||
* @param array<int, array<int|float>> $matrix Matrix
|
||||
*
|
||||
* @return Matrix
|
||||
*
|
||||
|
|
@ -591,7 +591,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
|||
/**
|
||||
* Trianglize matrix.
|
||||
*
|
||||
* @param array<int, array<float|int>> $arr Matrix to trianglize
|
||||
* @param array<int, array<int|float>> $arr Matrix to trianglize
|
||||
*
|
||||
* @return int Det sign
|
||||
*
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ final class Integer
|
|||
*
|
||||
* @param int $value Integer to factorize
|
||||
*
|
||||
* @return array<float|int>
|
||||
* @return array<int|float>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ interface InterpolationInterface
|
|||
/**
|
||||
* Interpolation at a given point
|
||||
*
|
||||
* @param float|int $x X-Coordinate to interpolate at
|
||||
* @param int|float $x X-Coordinate to interpolate at
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ final class Average
|
|||
/**
|
||||
* Average change.
|
||||
*
|
||||
* @param array<int, float|int> $x Dataset
|
||||
* @param array<int, int|float> $x Dataset
|
||||
* @param int $h Future steps
|
||||
*
|
||||
* @return float
|
||||
|
|
@ -69,9 +69,9 @@ final class Average
|
|||
/**
|
||||
* Moving average of dataset (SMA)
|
||||
*
|
||||
* @param array<int, float|int> $x Dataset
|
||||
* @param array<int, int|float> $x Dataset
|
||||
* @param int $order Periods to use for average
|
||||
* @param array<int, float|int> $weight Weight for moving average
|
||||
* @param array<int, int|float> $weight Weight for moving average
|
||||
* @param bool $symmetric Cyclic moving average
|
||||
*
|
||||
* @return float[] Moving average of data
|
||||
|
|
@ -96,10 +96,10 @@ final class Average
|
|||
/**
|
||||
* Moving average of element in dataset (SMA)
|
||||
*
|
||||
* @param array<int, float|int> $x Dataset
|
||||
* @param array<int, int|float> $x Dataset
|
||||
* @param int $t Current period
|
||||
* @param int $order Periods to use for average
|
||||
* @param array<int, float|int> $weight Weight for moving average
|
||||
* @param array<int, int|float> $weight Weight for moving average
|
||||
* @param bool $symmetric Cyclic moving average
|
||||
*
|
||||
* @return float Moving average
|
||||
|
|
@ -133,8 +133,8 @@ final class Average
|
|||
*
|
||||
* Example: ([1, 2, 3, 4], [0.25, 0.5, 0.125, 0.125])
|
||||
*
|
||||
* @param array<int, float|int> $values Values
|
||||
* @param array<int, float|int> $weight Weight for values
|
||||
* @param array<int, int|float> $values Values
|
||||
* @param array<int, int|float> $weight Weight for values
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -162,7 +162,7 @@ final class Average
|
|||
*
|
||||
* Example: ([1, 2, 2, 3, 4, 4, 2])
|
||||
*
|
||||
* @param array<int, float|int> $values Values
|
||||
* @param array<int, int|float> $values Values
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -186,7 +186,7 @@ final class Average
|
|||
*
|
||||
* Example: ([1, 2, 2, 3, 4, 4, 2])
|
||||
*
|
||||
* @param array<int, float|int> $values Values
|
||||
* @param array<int, int|float> $values Values
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -205,7 +205,7 @@ final class Average
|
|||
*
|
||||
* Example: ([1, 2, 2, 3, 4, 4, 2])
|
||||
*
|
||||
* @param array<int, float|int> $values Values
|
||||
* @param array<int, int|float> $values Values
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -233,7 +233,7 @@ final class Average
|
|||
*
|
||||
* Example: ([1, 2, 2, 3, 4, 4, 2])
|
||||
*
|
||||
* @param array<int, float|int> $values Values
|
||||
* @param array<int, int|float> $values Values
|
||||
* @param int $offset Offset for outlier
|
||||
*
|
||||
* @return float
|
||||
|
|
@ -258,7 +258,7 @@ final class Average
|
|||
*
|
||||
* Example: ([1, 2, 2, 3, 4, 4, 2])
|
||||
*
|
||||
* @param array<int, float|int> $values Values
|
||||
* @param array<int, int|float> $values Values
|
||||
* @param int $offset Offset for outlier
|
||||
*
|
||||
* @return float
|
||||
|
|
@ -302,7 +302,7 @@ final class Average
|
|||
*
|
||||
* Example: ([1, 2, 2, 3, 4, 4, 2])
|
||||
*
|
||||
* @param array<int, float|int> $angles Angles
|
||||
* @param array<int, int|float> $angles Angles
|
||||
* @param int $offset Offset for outlier
|
||||
*
|
||||
* @return float
|
||||
|
|
@ -331,7 +331,7 @@ final class Average
|
|||
*
|
||||
* Example: ([1, 2, 2, 3, 4, 4, 2])
|
||||
*
|
||||
* @param array<int, float|int> $angles Angles
|
||||
* @param array<int, int|float> $angles Angles
|
||||
* @param int $offset Offset for outlier
|
||||
*
|
||||
* @return float
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ final class Basic
|
|||
*
|
||||
* Example: ([4, 5, 9, 1, 3])
|
||||
*
|
||||
* @param array<array|float|int> $values Values
|
||||
* @param array<array|int|float> $values Values
|
||||
*
|
||||
* @return array<array|float|int>
|
||||
* @return array<array|int|float>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ final class Correlation
|
|||
*
|
||||
* Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3])
|
||||
*
|
||||
* @param array<float|int> $x Values
|
||||
* @param array<float|int> $y Values
|
||||
* @param array<int|float> $x Values
|
||||
* @param array<int|float> $y Values
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -54,7 +54,7 @@ final class Correlation
|
|||
/**
|
||||
* Get the autocorrelation coefficient (ACF).
|
||||
*
|
||||
* @param array<float|int> $x Dataset
|
||||
* @param array<int|float> $x Dataset
|
||||
* @param int $k k-th coefficient
|
||||
*
|
||||
* @return float
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ final class Forecasts
|
|||
* @param float $standardDeviation Standard Deviation of forecast
|
||||
* @param float $interval Forecast multiplier for prediction intervals
|
||||
*
|
||||
* @return array<float|int>
|
||||
* @return array<int|float>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ final class MultipleLinearRegression extends RegressionAbstract
|
|||
*
|
||||
* @latex y = b_{0} + b_{1} \cdot x
|
||||
*
|
||||
* @param array<array<float|int>> $x Obersved x values
|
||||
* @param array<array<float|int>> $y Observed y values
|
||||
* @param array<array<int|float>> $x Obersved x values
|
||||
* @param array<array<int|float>> $y Observed y values
|
||||
*
|
||||
* @return array [b0 => ?, b1 => ?]
|
||||
*
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ final class PolynomialRegression
|
|||
/**
|
||||
* Get linear regression based on scatter plot.
|
||||
*
|
||||
* @param array<float|int> $x Obersved x values
|
||||
* @param array<float|int> $y Observed y values
|
||||
* @param array<int|float> $x Obersved x values
|
||||
* @param array<int|float> $y Observed y values
|
||||
*
|
||||
* @return array [a => ?, b => ?, c => ?]
|
||||
*
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ abstract class RegressionAbstract
|
|||
*
|
||||
* @latex y = b_{0} + b_{1} \cdot x
|
||||
*
|
||||
* @param array<float|int> $x Obersved x values
|
||||
* @param array<float|int> $y Observed y values
|
||||
* @param array<int|float> $x Obersved x values
|
||||
* @param array<int|float> $y Observed y values
|
||||
*
|
||||
* @return array [b0 => ?, b1 => ?]
|
||||
*
|
||||
|
|
@ -59,7 +59,7 @@ abstract class RegressionAbstract
|
|||
*
|
||||
* @latex s_{e} = \sqrt{\frac{1}{N - 2}\sum_{i = 1}^{N} e_{i}^{2}}
|
||||
*
|
||||
* @param array<float|int> $errors Errors (e = y - y_forecasted)
|
||||
* @param array<int|float> $errors Errors (e = y - y_forecasted)
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -84,7 +84,7 @@ abstract class RegressionAbstract
|
|||
*
|
||||
* @latex s_{e} = \sqrt{\frac{1}{N - 2}\sum_{i = 1}^{N} e_{i}^{2}}
|
||||
*
|
||||
* @param array<float|int> $errors Errors (e = y - y_forecasted)
|
||||
* @param array<int|float> $errors Errors (e = y - y_forecasted)
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -109,11 +109,11 @@ abstract class RegressionAbstract
|
|||
*
|
||||
* @param float $fX Forecasted at x value
|
||||
* @param float $fY Forecasted y value
|
||||
* @param array<float|int> $x observex x values
|
||||
* @param array<int|float> $x observex x values
|
||||
* @param float $mse Errors for y values (y - y_forecasted)
|
||||
* @param float $multiplier Multiplier for interval
|
||||
*
|
||||
* @return array<float|int>
|
||||
* @return array<int|float>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -137,8 +137,8 @@ abstract class RegressionAbstract
|
|||
*
|
||||
* @latex \beta_{1} = \frac{\sum_{i=1}^{N} \left(y_{i} - \bar{y}\right)\left(x_{i} - \bar{x}\right)}{\sum_{i=1}^{N} \left(x_{i} - \bar{x}\right)^{2}}
|
||||
*
|
||||
* @param array<float|int> $x Obersved x values
|
||||
* @param array<float|int> $y Observed y values
|
||||
* @param array<int|float> $x Obersved x values
|
||||
* @param array<int|float> $y Observed y values
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -166,8 +166,8 @@ abstract class RegressionAbstract
|
|||
*
|
||||
* @latex \beta_{0} = \bar{x} - b_{1} \cdot \bar{x}
|
||||
*
|
||||
* @param array<float|int> $x Obersved x values
|
||||
* @param array<float|int> $y Observed y values
|
||||
* @param array<int|float> $x Obersved x values
|
||||
* @param array<int|float> $y Observed y values
|
||||
* @param float $b1 Beta 1
|
||||
*
|
||||
* @return float
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ final class MeasureOfDispersion
|
|||
*
|
||||
* Example: ([4, 5, 9, 1, 3])
|
||||
*
|
||||
* @param array<int, float|int> $values Values
|
||||
* @param array<int, int|float> $values Values
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -62,7 +62,7 @@ final class MeasureOfDispersion
|
|||
*
|
||||
* Example: ([4, 5, 9, 1, 3])
|
||||
*
|
||||
* @param array<int, float|int> $values Values
|
||||
* @param array<int, int|float> $values Values
|
||||
* @param float $mean Mean
|
||||
*
|
||||
* @return float
|
||||
|
|
@ -89,7 +89,7 @@ final class MeasureOfDispersion
|
|||
*
|
||||
* @latex \sigma = \sqrt{\sigma^{2}} = \sqrt{Var(X)}
|
||||
*
|
||||
* @param array<int, float|int> $values Values
|
||||
* @param array<int, int|float> $values Values
|
||||
* @param float $mean Mean
|
||||
*
|
||||
* @return float
|
||||
|
|
@ -117,7 +117,7 @@ final class MeasureOfDispersion
|
|||
*
|
||||
* @latex \sigma^{2} = Var(X) = \frac{1}{N - 1} \sum_{i = 1}^{N}\left(x_{i} - \bar{X}\right)^{2}
|
||||
*
|
||||
* @param array<int, float|int> $values Values
|
||||
* @param array<int, int|float> $values Values
|
||||
* @param float $mean Mean
|
||||
*
|
||||
* @return float
|
||||
|
|
@ -146,8 +146,8 @@ final class MeasureOfDispersion
|
|||
*
|
||||
* @latex \sigma^{2} = Var(X) = \frac{1}{N} \sum_{i = 1}^{N}\left(x_{i} - \bar{X}\right)^{2}
|
||||
*
|
||||
* @param array<int, float|int> $values Values
|
||||
* @param array<int, float|int> $probabilities Probabilities
|
||||
* @param array<int, int|float> $values Values
|
||||
* @param array<int, int|float> $probabilities Probabilities
|
||||
* @param float $mean Mean
|
||||
*
|
||||
* @return float
|
||||
|
|
@ -182,8 +182,8 @@ final class MeasureOfDispersion
|
|||
*
|
||||
* @latex \sigma_{XY} = cov(X, Y) = \sum_{i = 1}^{N}\frac{\left(x_{i} - \bar{X}\right) \left(y_{i} - \bar{Y}\right)}{N - 1}
|
||||
*
|
||||
* @param array<int, float|int> $x Values
|
||||
* @param array<int, float|int> $y Values
|
||||
* @param array<int, int|float> $x Values
|
||||
* @param array<int, int|float> $y Values
|
||||
* @param float $meanX Mean
|
||||
* @param float $meanY Mean
|
||||
*
|
||||
|
|
@ -221,7 +221,7 @@ final class MeasureOfDispersion
|
|||
/**
|
||||
* Get interquartile range.
|
||||
*
|
||||
* @param array<int, float|int> $x Dataset
|
||||
* @param array<int, int|float> $x Dataset
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
|
|
@ -249,7 +249,7 @@ final class MeasureOfDispersion
|
|||
/**
|
||||
* Get mean deviation.
|
||||
*
|
||||
* @param array<int, float|int> $x Values
|
||||
* @param array<int, int|float> $x Values
|
||||
* @param float $mean Mean
|
||||
* @param int $offset Population/Size offset
|
||||
*
|
||||
|
|
@ -272,7 +272,7 @@ final class MeasureOfDispersion
|
|||
/**
|
||||
* Get the deviation to the mean
|
||||
*
|
||||
* @param array<int, float|int> $x Values
|
||||
* @param array<int, int|float> $x Values
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
|
|
@ -292,7 +292,7 @@ final class MeasureOfDispersion
|
|||
/**
|
||||
* Get mean absolute deviation.
|
||||
*
|
||||
* @param array<int, float|int> $x Values
|
||||
* @param array<int, int|float> $x Values
|
||||
* @param float $mean Mean
|
||||
* @param int $offset Population/Size offset
|
||||
*
|
||||
|
|
@ -315,7 +315,7 @@ final class MeasureOfDispersion
|
|||
/**
|
||||
* Get the deviation to the mean
|
||||
*
|
||||
* @param array<int, float|int> $x Values
|
||||
* @param array<int, int|float> $x Values
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
|
|
@ -335,7 +335,7 @@ final class MeasureOfDispersion
|
|||
/**
|
||||
* Get squared mean deviation.
|
||||
*
|
||||
* @param array<int, float|int> $x Values
|
||||
* @param array<int, int|float> $x Values
|
||||
* @param float $mean Mean
|
||||
* @param int $offset Population/Size offset
|
||||
*
|
||||
|
|
@ -358,7 +358,7 @@ final class MeasureOfDispersion
|
|||
/**
|
||||
* Get the deviation to the mean squared
|
||||
*
|
||||
* @param array<int, float|int> $x Values
|
||||
* @param array<int, int|float> $x Values
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ namespace phpOMS\Message\Socket;
|
|||
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\System\MimeType;
|
||||
|
||||
/**
|
||||
* Response class.
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ final class MultiMap implements \Countable
|
|||
/**
|
||||
* Associated keys for values.
|
||||
*
|
||||
* @var array<int|string, int|string>
|
||||
* @var array<int|string, int|string>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $keys = [];
|
||||
|
|
@ -75,7 +75,7 @@ final class MultiMap implements \Countable
|
|||
/**
|
||||
* Add data.
|
||||
*
|
||||
* @param array<float|int|string> $keys Keys for value
|
||||
* @param array<int|float|string> $keys Keys for value
|
||||
* @param mixed $value Value to store
|
||||
* @param bool $overwrite Add value if key exists
|
||||
*
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ final class UriFactory
|
|||
* $ = Other data
|
||||
*
|
||||
* @param string $uri Path data
|
||||
* @param array<string, bool|float|int|string> $toMatch Optional special replacements
|
||||
* @param array<string, bool|int|float|string> $toMatch Optional special replacements
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ final class ArrayUtils
|
|||
* @param int $start Start index
|
||||
* @param int $count Amount of elements to sum
|
||||
*
|
||||
* @return float|int
|
||||
* @return int|float
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -366,9 +366,9 @@ final class ArrayUtils
|
|||
/**
|
||||
* Applying abs to every array value
|
||||
*
|
||||
* @param array<float|int> $values Numeric values
|
||||
* @param array<int|float> $values Numeric values
|
||||
*
|
||||
* @return array<float|int>
|
||||
* @return array<int|float>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -386,7 +386,7 @@ final class ArrayUtils
|
|||
/**
|
||||
* Power all values in array.
|
||||
*
|
||||
* @param array<float|int> $values Values to square
|
||||
* @param array<int|float> $values Values to square
|
||||
* @param float $exp Exponent
|
||||
*
|
||||
* @return float[]
|
||||
|
|
@ -410,10 +410,10 @@ final class ArrayUtils
|
|||
/**
|
||||
* Power all values in array.
|
||||
*
|
||||
* @param array<float|int> $values Values to square
|
||||
* @param array<int|float> $values Values to square
|
||||
* @param int $exp Exponent
|
||||
*
|
||||
* @return array<float|int>
|
||||
* @return array<int|float>
|
||||
*
|
||||
* @todo Orange-Management/phpOMS#223
|
||||
* In the ArrayUtils class the power* functions should be combined once union types become available.
|
||||
|
|
@ -434,9 +434,9 @@ final class ArrayUtils
|
|||
/**
|
||||
* Sqrt all values in array.
|
||||
*
|
||||
* @param array<float|int> $values Values to sqrt
|
||||
* @param array<int|float> $values Values to sqrt
|
||||
*
|
||||
* @return array<float|int>
|
||||
* @return array<int|float>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class LZW implements CompressionInterface
|
|||
}
|
||||
|
||||
$w = \chr((int) $compressed[0]);
|
||||
$result = $dictionary[(int) ($compressed[0])] ?? 0;
|
||||
$result = $dictionary[(int) ($compressed[0])] ?? '';
|
||||
$count = \count($compressed);
|
||||
|
||||
for ($i = 1; $i < $count; ++$i) {
|
||||
|
|
@ -97,6 +97,7 @@ class LZW implements CompressionInterface
|
|||
$w = $entry;
|
||||
}
|
||||
|
||||
/** @var string $result */
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,9 +142,9 @@ final class Validator extends ValidatorAbstract
|
|||
/**
|
||||
* Validate variable by interval.
|
||||
*
|
||||
* @param float|int $var Variable to validate
|
||||
* @param float|int $min Min. value
|
||||
* @param float|int $max Max. value
|
||||
* @param int|float $var Variable to validate
|
||||
* @param int|float $min Min. value
|
||||
* @param int|float $max Max. value
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace phpOMS\Views;
|
||||
|
||||
use phpOMS\ApplicationAbstract;
|
||||
use phpOMS\Localization\L11nManager;
|
||||
use phpOMS\Localization\Localization;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
|
|
@ -50,10 +50,10 @@ class View extends ViewAbstract
|
|||
/**
|
||||
* Application.
|
||||
*
|
||||
* @var null|ApplicationAbstract
|
||||
* @var null|L11nManager
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?ApplicationAbstract $app;
|
||||
protected ?L11nManager $l11nManager;
|
||||
|
||||
/**
|
||||
* Request.
|
||||
|
|
@ -90,18 +90,18 @@ class View extends ViewAbstract
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Request
|
||||
* @param L11nManager $l11n Application
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Request
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(ApplicationAbstract $app = null, RequestAbstract $request = null, ResponseAbstract $response = null)
|
||||
public function __construct(L11nManager $l11n = null, RequestAbstract $request = null, ResponseAbstract $response = null)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
$this->l11n = $response !== null ? $response->getHeader()->getL11n() : new Localization();
|
||||
$this->l11nManager = $l11n;
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
$this->l11n = $response !== null ? $response->getHeader()->getL11n() : new Localization();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -187,6 +187,10 @@ class View extends ViewAbstract
|
|||
*/
|
||||
public function getText($translation, string $module = null, string $theme = null) : string
|
||||
{
|
||||
if ($this->l11nManager === null) {
|
||||
return 'ERROR';
|
||||
}
|
||||
|
||||
if ($module === null && $this->module === null) {
|
||||
$this->setModuleDynamically();
|
||||
}
|
||||
|
|
@ -200,7 +204,7 @@ class View extends ViewAbstract
|
|||
/** @var string $theme */
|
||||
$theme = $theme ?? $this->theme;
|
||||
|
||||
return $this->app->l11nManager->getText($this->l11n->getLanguage() ?? 'en', $module, $theme, $translation);
|
||||
return $this->l11nManager->getText($this->l11n->getLanguage() ?? 'en', $module, $theme, $translation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
$view = new View($this->app, new Request(new Http('')), new Response(new Localization()));
|
||||
$view = new View($this->app->l11nManager, new Request(new Http('')), new Response(new Localization()));
|
||||
|
||||
self::assertEmpty($view->getTemplate());
|
||||
self::assertEmpty($view->getViews());
|
||||
|
|
@ -78,7 +78,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testGetText() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
$view->setTemplate('/Modules/Admin/Theme/Backend/accounts-list');
|
||||
|
||||
$expected = [
|
||||
|
|
@ -102,7 +102,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testGetHtml() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
$view->setTemplate('/Modules/Admin/Theme/Backend/accounts-list');
|
||||
|
||||
$expected = [
|
||||
|
|
@ -126,7 +126,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testDataInputOutput() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
$view->setData('key', 'value');
|
||||
self::assertEquals('value', $view->getData('key'));
|
||||
|
|
@ -139,7 +139,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testDataAdd() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
self::assertTrue($view->addData('key2', 'valu2'));
|
||||
self::assertEquals('valu2', $view->getData('key2'));
|
||||
|
|
@ -152,7 +152,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testInvalidDataOverwrite() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
$view->addData('key2', 'valu2');
|
||||
self::assertFalse($view->addData('key2', 'valu3'));
|
||||
|
|
@ -166,7 +166,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testRemove() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
$view->addData('key2', 'valu2');
|
||||
self::assertTrue($view->removeData('key2'));
|
||||
|
|
@ -179,7 +179,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testInvalidDataRemove() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
self::assertFalse($view->removeData('key3'));
|
||||
}
|
||||
|
|
@ -191,7 +191,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testGetRequest() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
self::assertEquals($request, $view->getRequest());
|
||||
self::assertEquals($response, $view->getResponse());
|
||||
|
|
@ -204,7 +204,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testGetResponse() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
self::assertEquals($response, $view->getResponse());
|
||||
}
|
||||
|
|
@ -216,7 +216,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testPrintHtml() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
self::assertEquals('<a href="test">Test</a>', $view->printHtml('<a href="test">Test</a>'));
|
||||
self::assertEquals('<a href="test">Test</a>', ViewAbstract::html('<a href="test">Test</a>'));
|
||||
|
|
@ -229,9 +229,9 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testViewInputOutput() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
$tView = new View($this->app, $request, $response);
|
||||
$tView = new View($this->app->l11nManager, $request, $response);
|
||||
self::assertTrue($view->addView('test', $tView));
|
||||
self::assertEquals($tView, $view->getView('test'));
|
||||
self::assertCount(1, $view->getViews());
|
||||
|
|
@ -244,7 +244,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testInvalidViewGet() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
self::assertFalse($view->getView('test'));
|
||||
}
|
||||
|
|
@ -256,9 +256,9 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testViewRemove() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
$tView = new View($this->app, $request, $response);
|
||||
$tView = new View($this->app->l11nManager, $request, $response);
|
||||
$view->addView('test', $tView);
|
||||
self::assertTrue($view->removeView('test'));
|
||||
}
|
||||
|
|
@ -270,7 +270,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testInvalidViewRemove() : void
|
||||
{
|
||||
$view = new View($this->app, $request = new Request(new Http('')), $response = new Response());
|
||||
$view = new View($this->app->l11nManager, $request = new Request(new Http('')), $response = new Response());
|
||||
|
||||
self::assertFalse($view->removeView('test'));
|
||||
}
|
||||
|
|
@ -363,7 +363,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
self::expectException(\phpOMS\System\File\PathException::class);
|
||||
|
||||
$view = new View($this->app);
|
||||
$view = new View($this->app->l11nManager);
|
||||
$view->setTemplate('something.txt');
|
||||
|
||||
$view->render();
|
||||
|
|
@ -378,7 +378,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
self::expectException(\phpOMS\System\File\PathException::class);
|
||||
|
||||
$view = new View($this->app);
|
||||
$view = new View($this->app->l11nManager);
|
||||
$view->setTemplate('something.txt');
|
||||
|
||||
$view->serialize();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user