improve baseline

This commit is contained in:
Dennis Eichhorn 2020-02-06 23:53:39 +01:00
parent fb968fbef7
commit 3aed840c77
25 changed files with 126 additions and 120 deletions

View File

@ -52,7 +52,7 @@ class Backpack implements BackpackInterface
/** /**
* Items inside the backpack * Items inside the backpack
* *
* @var ItemInterface[] * @var array<int, array{item:ItemInterface, quantity:int|float}>
* @since 1.0.0 * @since 1.0.0
*/ */
private array $items = []; private array $items = [];

View File

@ -952,7 +952,7 @@ final class FinanceFormulas
* *
* Also known as compounded annual growth rate. * 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 * @return float
* *
@ -1080,7 +1080,7 @@ final class FinanceFormulas
/** /**
* Net Present Value * 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 * @param float $r Discount rate
* *
* @return float * @return float

View File

@ -37,7 +37,7 @@ final class Lorenzkurve
/** /**
* Calculate Gini coefficient * 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 * @return float Returns the gini coefficient
* *

View File

@ -208,7 +208,7 @@ final class StockBonds
/** /**
* Holding Period Return * Holding Period Return
* *
* @param array<float|int> $r Rate of return * @param array<int|float> $r Rate of return
* *
* @return float * @return float
* *

View File

@ -75,7 +75,7 @@ final class Money implements \Serializable
/** /**
* Constructor. * Constructor.
* *
* @param float|int|string $value Value * @param int|float|string $value Value
* @param string $thousands Thousands separator * @param string $thousands Thousands separator
* @param string $decimal Decimal separator * @param string $decimal Decimal separator
* @param string $symbol Currency symbol * @param string $symbol Currency symbol
@ -208,7 +208,7 @@ final class Money implements \Serializable
/** /**
* Add money. * Add money.
* *
* @param float|int|Money|string $value Value to add * @param int|float|Money|string $value Value to add
* *
* @return Money * @return Money
* *
@ -242,7 +242,7 @@ final class Money implements \Serializable
/** /**
* Sub money. * Sub money.
* *
* @param float|int|Money|string $value Value to subtract * @param int|float|Money|string $value Value to subtract
* *
* @return Money * @return Money
* *
@ -264,7 +264,7 @@ final class Money implements \Serializable
/** /**
* Mult. * Mult.
* *
* @param float|int $value Value to multiply with * @param int|float $value Value to multiply with
* *
* @return Money * @return Money
* *
@ -282,7 +282,7 @@ final class Money implements \Serializable
/** /**
* Div. * Div.
* *
* @param float|int $value Value to divide by * @param int|float $value Value to divide by
* *
* @return Money * @return Money
* *
@ -314,7 +314,7 @@ final class Money implements \Serializable
/** /**
* Power. * Power.
* *
* @param float|int $value Value to power * @param int|float $value Value to power
* *
* @return Money * @return Money
* *

View File

@ -37,9 +37,9 @@ final class MonotoneChain
/** /**
* Create convex hull * 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 * @since 1.0.0
*/ */
@ -80,9 +80,9 @@ final class MonotoneChain
/** /**
* Counter clock wise turn? * Counter clock wise turn?
* *
* @param array{x:float|int, y:float|int} $a Point a * @param array{x:int|float, y:int|float} $a Point a
* @param array{x:float|int, y:float|int} $b Point b * @param array{x:int|float, y:int|float} $b Point b
* @param array{x:float|int, y:float|int} $c Point c * @param array{x:int|float, y:int|float} $c Point c
* *
* @return float * @return float
* *
@ -96,8 +96,8 @@ final class MonotoneChain
/** /**
* Sort by x coordinate then by z coordinate * Sort by x coordinate then by z coordinate
* *
* @param array{x:float|int, y:float|int} $a Point a * @param array{x:int|float, y:int|float} $a Point a
* @param array{x:float|int, y:float|int} $b Point b * @param array{x:int|float, y:int|float} $b Point b
* *
* @return float * @return float
* *

View File

@ -79,9 +79,9 @@ class Matrix implements \ArrayAccess, \Iterator
/** /**
* Set value. * Set value.
* *
* @param int $m Row * @param int $m Row
* @param int $n Column * @param int $n Column
* @param int $value Value * @param int|float $value Value
* *
* @return void * @return void
* *
@ -336,7 +336,7 @@ class Matrix implements \ArrayAccess, \Iterator
/** /**
* Set matrix array. * Set matrix array.
* *
* @param array<int, array<float|int>> $matrix Matrix * @param array<int, array<int|float>> $matrix Matrix
* *
* @return Matrix * @return Matrix
* *
@ -591,7 +591,7 @@ class Matrix implements \ArrayAccess, \Iterator
/** /**
* Trianglize matrix. * 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 * @return int Det sign
* *

View File

@ -53,7 +53,7 @@ final class Integer
* *
* @param int $value Integer to factorize * @param int $value Integer to factorize
* *
* @return array<float|int> * @return array<int|float>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -27,7 +27,7 @@ interface InterpolationInterface
/** /**
* Interpolation at a given point * 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 * @return float
* *

View File

@ -52,7 +52,7 @@ final class Average
/** /**
* Average change. * Average change.
* *
* @param array<int, float|int> $x Dataset * @param array<int, int|float> $x Dataset
* @param int $h Future steps * @param int $h Future steps
* *
* @return float * @return float
@ -69,9 +69,9 @@ final class Average
/** /**
* Moving average of dataset (SMA) * 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 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 * @param bool $symmetric Cyclic moving average
* *
* @return float[] Moving average of data * @return float[] Moving average of data
@ -96,10 +96,10 @@ final class Average
/** /**
* Moving average of element in dataset (SMA) * 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 $t Current period
* @param int $order Periods to use for average * @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 * @param bool $symmetric Cyclic moving average
* *
* @return float 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]) * Example: ([1, 2, 3, 4], [0.25, 0.5, 0.125, 0.125])
* *
* @param array<int, float|int> $values Values * @param array<int, int|float> $values Values
* @param array<int, float|int> $weight Weight for values * @param array<int, int|float> $weight Weight for values
* *
* @return float * @return float
* *
@ -162,7 +162,7 @@ final class Average
* *
* Example: ([1, 2, 2, 3, 4, 4, 2]) * Example: ([1, 2, 2, 3, 4, 4, 2])
* *
* @param array<int, float|int> $values Values * @param array<int, int|float> $values Values
* *
* @return float * @return float
* *
@ -186,7 +186,7 @@ final class Average
* *
* Example: ([1, 2, 2, 3, 4, 4, 2]) * Example: ([1, 2, 2, 3, 4, 4, 2])
* *
* @param array<int, float|int> $values Values * @param array<int, int|float> $values Values
* *
* @return float * @return float
* *
@ -205,7 +205,7 @@ final class Average
* *
* Example: ([1, 2, 2, 3, 4, 4, 2]) * Example: ([1, 2, 2, 3, 4, 4, 2])
* *
* @param array<int, float|int> $values Values * @param array<int, int|float> $values Values
* *
* @return float * @return float
* *
@ -233,7 +233,7 @@ final class Average
* *
* Example: ([1, 2, 2, 3, 4, 4, 2]) * 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 * @param int $offset Offset for outlier
* *
* @return float * @return float
@ -258,7 +258,7 @@ final class Average
* *
* Example: ([1, 2, 2, 3, 4, 4, 2]) * 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 * @param int $offset Offset for outlier
* *
* @return float * @return float
@ -302,7 +302,7 @@ final class Average
* *
* Example: ([1, 2, 2, 3, 4, 4, 2]) * 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 * @param int $offset Offset for outlier
* *
* @return float * @return float
@ -331,7 +331,7 @@ final class Average
* *
* Example: ([1, 2, 2, 3, 4, 4, 2]) * 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 * @param int $offset Offset for outlier
* *
* @return float * @return float

View File

@ -39,9 +39,9 @@ final class Basic
* *
* Example: ([4, 5, 9, 1, 3]) * 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 * @since 1.0.0
*/ */

View File

@ -39,8 +39,8 @@ final class Correlation
* *
* Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3]) * Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3])
* *
* @param array<float|int> $x Values * @param array<int|float> $x Values
* @param array<float|int> $y Values * @param array<int|float> $y Values
* *
* @return float * @return float
* *
@ -54,7 +54,7 @@ final class Correlation
/** /**
* Get the autocorrelation coefficient (ACF). * Get the autocorrelation coefficient (ACF).
* *
* @param array<float|int> $x Dataset * @param array<int|float> $x Dataset
* @param int $k k-th coefficient * @param int $k k-th coefficient
* *
* @return float * @return float

View File

@ -31,7 +31,7 @@ final class Forecasts
* @param float $standardDeviation Standard Deviation of forecast * @param float $standardDeviation Standard Deviation of forecast
* @param float $interval Forecast multiplier for prediction intervals * @param float $interval Forecast multiplier for prediction intervals
* *
* @return array<float|int> * @return array<int|float>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -30,8 +30,8 @@ final class MultipleLinearRegression extends RegressionAbstract
* *
* @latex y = b_{0} + b_{1} \cdot x * @latex y = b_{0} + b_{1} \cdot x
* *
* @param array<array<float|int>> $x Obersved x values * @param array<array<int|float>> $x Obersved x values
* @param array<array<float|int>> $y Observed y values * @param array<array<int|float>> $y Observed y values
* *
* @return array [b0 => ?, b1 => ?] * @return array [b0 => ?, b1 => ?]
* *

View File

@ -30,8 +30,8 @@ final class PolynomialRegression
/** /**
* Get linear regression based on scatter plot. * Get linear regression based on scatter plot.
* *
* @param array<float|int> $x Obersved x values * @param array<int|float> $x Obersved x values
* @param array<float|int> $y Observed y values * @param array<int|float> $y Observed y values
* *
* @return array [a => ?, b => ?, c => ?] * @return array [a => ?, b => ?, c => ?]
* *

View File

@ -32,8 +32,8 @@ abstract class RegressionAbstract
* *
* @latex y = b_{0} + b_{1} \cdot x * @latex y = b_{0} + b_{1} \cdot x
* *
* @param array<float|int> $x Obersved x values * @param array<int|float> $x Obersved x values
* @param array<float|int> $y Observed y values * @param array<int|float> $y Observed y values
* *
* @return array [b0 => ?, b1 => ?] * @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}} * @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 * @return float
* *
@ -84,7 +84,7 @@ abstract class RegressionAbstract
* *
* @latex s_{e} = \sqrt{\frac{1}{N - 2}\sum_{i = 1}^{N} e_{i}^{2}} * @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 * @return float
* *
@ -109,11 +109,11 @@ abstract class RegressionAbstract
* *
* @param float $fX Forecasted at x value * @param float $fX Forecasted at x value
* @param float $fY Forecasted y 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 $mse Errors for y values (y - y_forecasted)
* @param float $multiplier Multiplier for interval * @param float $multiplier Multiplier for interval
* *
* @return array<float|int> * @return array<int|float>
* *
* @since 1.0.0 * @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}} * @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<int|float> $x Obersved x values
* @param array<float|int> $y Observed y values * @param array<int|float> $y Observed y values
* *
* @return float * @return float
* *
@ -166,8 +166,8 @@ abstract class RegressionAbstract
* *
* @latex \beta_{0} = \bar{x} - b_{1} \cdot \bar{x} * @latex \beta_{0} = \bar{x} - b_{1} \cdot \bar{x}
* *
* @param array<float|int> $x Obersved x values * @param array<int|float> $x Obersved x values
* @param array<float|int> $y Observed y values * @param array<int|float> $y Observed y values
* @param float $b1 Beta 1 * @param float $b1 Beta 1
* *
* @return float * @return float

View File

@ -42,7 +42,7 @@ final class MeasureOfDispersion
* *
* Example: ([4, 5, 9, 1, 3]) * Example: ([4, 5, 9, 1, 3])
* *
* @param array<int, float|int> $values Values * @param array<int, int|float> $values Values
* *
* @return float * @return float
* *
@ -62,7 +62,7 @@ final class MeasureOfDispersion
* *
* Example: ([4, 5, 9, 1, 3]) * Example: ([4, 5, 9, 1, 3])
* *
* @param array<int, float|int> $values Values * @param array<int, int|float> $values Values
* @param float $mean Mean * @param float $mean Mean
* *
* @return float * @return float
@ -89,7 +89,7 @@ final class MeasureOfDispersion
* *
* @latex \sigma = \sqrt{\sigma^{2}} = \sqrt{Var(X)} * @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 * @param float $mean Mean
* *
* @return float * @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} * @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 * @param float $mean Mean
* *
* @return float * @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} * @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, int|float> $values Values
* @param array<int, float|int> $probabilities Probabilities * @param array<int, int|float> $probabilities Probabilities
* @param float $mean Mean * @param float $mean Mean
* *
* @return float * @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} * @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, int|float> $x Values
* @param array<int, float|int> $y Values * @param array<int, int|float> $y Values
* @param float $meanX Mean * @param float $meanX Mean
* @param float $meanY Mean * @param float $meanY Mean
* *
@ -221,7 +221,7 @@ final class MeasureOfDispersion
/** /**
* Get interquartile range. * Get interquartile range.
* *
* @param array<int, float|int> $x Dataset * @param array<int, int|float> $x Dataset
* *
* @return float * @return float
* *
@ -249,7 +249,7 @@ final class MeasureOfDispersion
/** /**
* Get mean deviation. * Get mean deviation.
* *
* @param array<int, float|int> $x Values * @param array<int, int|float> $x Values
* @param float $mean Mean * @param float $mean Mean
* @param int $offset Population/Size offset * @param int $offset Population/Size offset
* *
@ -272,7 +272,7 @@ final class MeasureOfDispersion
/** /**
* Get the deviation to the mean * Get the deviation to the mean
* *
* @param array<int, float|int> $x Values * @param array<int, int|float> $x Values
* *
* @return array * @return array
* *
@ -292,7 +292,7 @@ final class MeasureOfDispersion
/** /**
* Get mean absolute deviation. * Get mean absolute deviation.
* *
* @param array<int, float|int> $x Values * @param array<int, int|float> $x Values
* @param float $mean Mean * @param float $mean Mean
* @param int $offset Population/Size offset * @param int $offset Population/Size offset
* *
@ -315,7 +315,7 @@ final class MeasureOfDispersion
/** /**
* Get the deviation to the mean * Get the deviation to the mean
* *
* @param array<int, float|int> $x Values * @param array<int, int|float> $x Values
* *
* @return array * @return array
* *
@ -335,7 +335,7 @@ final class MeasureOfDispersion
/** /**
* Get squared mean deviation. * Get squared mean deviation.
* *
* @param array<int, float|int> $x Values * @param array<int, int|float> $x Values
* @param float $mean Mean * @param float $mean Mean
* @param int $offset Population/Size offset * @param int $offset Population/Size offset
* *
@ -358,7 +358,7 @@ final class MeasureOfDispersion
/** /**
* Get the deviation to the mean squared * Get the deviation to the mean squared
* *
* @param array<int, float|int> $x Values * @param array<int, int|float> $x Values
* *
* @return array * @return array
* *

View File

@ -16,6 +16,7 @@ namespace phpOMS\Message\Socket;
use phpOMS\Contract\RenderableInterface; use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\ResponseAbstract; use phpOMS\Message\ResponseAbstract;
use phpOMS\System\MimeType;
/** /**
* Response class. * Response class.

View File

@ -37,7 +37,7 @@ final class MultiMap implements \Countable
/** /**
* Associated keys for values. * Associated keys for values.
* *
* @var array<int|string, int|string> * @var array<int|string, int|string>
* @since 1.0.0 * @since 1.0.0
*/ */
private array $keys = []; private array $keys = [];
@ -75,7 +75,7 @@ final class MultiMap implements \Countable
/** /**
* Add data. * 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 mixed $value Value to store
* @param bool $overwrite Add value if key exists * @param bool $overwrite Add value if key exists
* *

View File

@ -225,7 +225,7 @@ final class UriFactory
* $ = Other data * $ = Other data
* *
* @param string $uri Path 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 * @return string
* *

View File

@ -332,7 +332,7 @@ final class ArrayUtils
* @param int $start Start index * @param int $start Start index
* @param int $count Amount of elements to sum * @param int $count Amount of elements to sum
* *
* @return float|int * @return int|float
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -366,9 +366,9 @@ final class ArrayUtils
/** /**
* Applying abs to every array value * 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 * @since 1.0.0
*/ */
@ -386,7 +386,7 @@ final class ArrayUtils
/** /**
* Power all values in array. * 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 * @param float $exp Exponent
* *
* @return float[] * @return float[]
@ -410,10 +410,10 @@ final class ArrayUtils
/** /**
* Power all values in array. * 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 * @param int $exp Exponent
* *
* @return array<float|int> * @return array<int|float>
* *
* @todo Orange-Management/phpOMS#223 * @todo Orange-Management/phpOMS#223
* In the ArrayUtils class the power* functions should be combined once union types become available. * 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. * 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 * @since 1.0.0
*/ */

View File

@ -78,7 +78,7 @@ class LZW implements CompressionInterface
} }
$w = \chr((int) $compressed[0]); $w = \chr((int) $compressed[0]);
$result = $dictionary[(int) ($compressed[0])] ?? 0; $result = $dictionary[(int) ($compressed[0])] ?? '';
$count = \count($compressed); $count = \count($compressed);
for ($i = 1; $i < $count; ++$i) { for ($i = 1; $i < $count; ++$i) {
@ -97,6 +97,7 @@ class LZW implements CompressionInterface
$w = $entry; $w = $entry;
} }
/** @var string $result */
return $result; return $result;
} }
} }

View File

@ -142,9 +142,9 @@ final class Validator extends ValidatorAbstract
/** /**
* Validate variable by interval. * Validate variable by interval.
* *
* @param float|int $var Variable to validate * @param int|float $var Variable to validate
* @param float|int $min Min. value * @param int|float $min Min. value
* @param float|int $max Max. value * @param int|float $max Max. value
* *
* @return bool * @return bool
* *

View File

@ -14,7 +14,7 @@ declare(strict_types=1);
namespace phpOMS\Views; namespace phpOMS\Views;
use phpOMS\ApplicationAbstract; use phpOMS\Localization\L11nManager;
use phpOMS\Localization\Localization; use phpOMS\Localization\Localization;
use phpOMS\Message\RequestAbstract; use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract; use phpOMS\Message\ResponseAbstract;
@ -50,10 +50,10 @@ class View extends ViewAbstract
/** /**
* Application. * Application.
* *
* @var null|ApplicationAbstract * @var null|L11nManager
* @since 1.0.0 * @since 1.0.0
*/ */
protected ?ApplicationAbstract $app; protected ?L11nManager $l11nManager;
/** /**
* Request. * Request.
@ -90,18 +90,18 @@ class View extends ViewAbstract
/** /**
* Constructor. * Constructor.
* *
* @param ApplicationAbstract $app Application * @param L11nManager $l11n Application
* @param RequestAbstract $request Request * @param RequestAbstract $request Request
* @param ResponseAbstract $response Request * @param ResponseAbstract $response Request
* *
* @since 1.0.0 * @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->l11nManager = $l11n;
$this->request = $request; $this->request = $request;
$this->response = $response; $this->response = $response;
$this->l11n = $response !== null ? $response->getHeader()->getL11n() : new Localization(); $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 public function getText($translation, string $module = null, string $theme = null) : string
{ {
if ($this->l11nManager === null) {
return 'ERROR';
}
if ($module === null && $this->module === null) { if ($module === null && $this->module === null) {
$this->setModuleDynamically(); $this->setModuleDynamically();
} }
@ -200,7 +204,7 @@ class View extends ViewAbstract
/** @var string $theme */ /** @var string $theme */
$theme = $theme ?? $this->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);
} }
/** /**

View File

@ -59,7 +59,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDefault() : void 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->getTemplate());
self::assertEmpty($view->getViews()); self::assertEmpty($view->getViews());
@ -78,7 +78,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testGetText() : void 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'); $view->setTemplate('/Modules/Admin/Theme/Backend/accounts-list');
$expected = [ $expected = [
@ -102,7 +102,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testGetHtml() : void 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'); $view->setTemplate('/Modules/Admin/Theme/Backend/accounts-list');
$expected = [ $expected = [
@ -126,7 +126,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDataInputOutput() : void 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'); $view->setData('key', 'value');
self::assertEquals('value', $view->getData('key')); self::assertEquals('value', $view->getData('key'));
@ -139,7 +139,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDataAdd() : void 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::assertTrue($view->addData('key2', 'valu2'));
self::assertEquals('valu2', $view->getData('key2')); self::assertEquals('valu2', $view->getData('key2'));
@ -152,7 +152,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testInvalidDataOverwrite() : void 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'); $view->addData('key2', 'valu2');
self::assertFalse($view->addData('key2', 'valu3')); self::assertFalse($view->addData('key2', 'valu3'));
@ -166,7 +166,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testRemove() : void 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'); $view->addData('key2', 'valu2');
self::assertTrue($view->removeData('key2')); self::assertTrue($view->removeData('key2'));
@ -179,7 +179,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testInvalidDataRemove() : void 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')); self::assertFalse($view->removeData('key3'));
} }
@ -191,7 +191,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testGetRequest() : void 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($request, $view->getRequest());
self::assertEquals($response, $view->getResponse()); self::assertEquals($response, $view->getResponse());
@ -204,7 +204,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testGetResponse() : void 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()); self::assertEquals($response, $view->getResponse());
} }
@ -216,7 +216,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testPrintHtml() : void 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('&lt;a href=&quot;test&quot;&gt;Test&lt;/a&gt;', $view->printHtml('<a href="test">Test</a>')); self::assertEquals('&lt;a href=&quot;test&quot;&gt;Test&lt;/a&gt;', $view->printHtml('<a href="test">Test</a>'));
self::assertEquals('&lt;a href=&quot;test&quot;&gt;Test&lt;/a&gt;', ViewAbstract::html('<a href="test">Test</a>')); self::assertEquals('&lt;a href=&quot;test&quot;&gt;Test&lt;/a&gt;', ViewAbstract::html('<a href="test">Test</a>'));
@ -229,9 +229,9 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testViewInputOutput() : void 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::assertTrue($view->addView('test', $tView));
self::assertEquals($tView, $view->getView('test')); self::assertEquals($tView, $view->getView('test'));
self::assertCount(1, $view->getViews()); self::assertCount(1, $view->getViews());
@ -244,7 +244,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testInvalidViewGet() : void 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')); self::assertFalse($view->getView('test'));
} }
@ -256,9 +256,9 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testViewRemove() : void 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); $view->addView('test', $tView);
self::assertTrue($view->removeView('test')); self::assertTrue($view->removeView('test'));
} }
@ -270,7 +270,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/ */
public function testInvalidViewRemove() : void 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')); self::assertFalse($view->removeView('test'));
} }
@ -363,7 +363,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
{ {
self::expectException(\phpOMS\System\File\PathException::class); self::expectException(\phpOMS\System\File\PathException::class);
$view = new View($this->app); $view = new View($this->app->l11nManager);
$view->setTemplate('something.txt'); $view->setTemplate('something.txt');
$view->render(); $view->render();
@ -378,7 +378,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
{ {
self::expectException(\phpOMS\System\File\PathException::class); self::expectException(\phpOMS\System\File\PathException::class);
$view = new View($this->app); $view = new View($this->app->l11nManager);
$view->setTemplate('something.txt'); $view->setTemplate('something.txt');
$view->serialize(); $view->serialize();