diff --git a/Localization/Localization.php b/Localization/Localization.php index 8c0c9bfaa..edfdb6a18 100644 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -359,7 +359,7 @@ class Localization */ public function setAngle(string $angle) { - $this->temperature = $angle; + $this->angle = $angle; } /** @@ -381,7 +381,7 @@ class Localization * @since 1.0.0 * @author Dennis Eichhorn */ - public function setTemperatur(string $temperature) + public function setTemperature(string $temperature) { $this->temperature = $temperature; } diff --git a/Localization/Money.php b/Localization/Money.php index 1676f0bf0..492131381 100644 --- a/Localization/Money.php +++ b/Localization/Money.php @@ -53,6 +53,22 @@ class Money implements \Serializable */ private $decimal = '.'; + /** + * Currency symbol position + * + * @var string + * @since 1.0.0 + */ + private $position = 1; + + /** + * Currency symbol. + * + * @var string + * @since 1.0.0 + */ + private $symbol = ISO4217SymbolEnum::_USD; + /** * Value. * @@ -118,6 +134,8 @@ class Money implements \Serializable * @param string $symbol Currency symbol * @param int $position Symbol position * + * @return Money + * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -127,6 +145,8 @@ class Money implements \Serializable $this->decimal = $decimal; $this->symbol = $symbol; $this->position = $position; + + return $this; } /** @@ -158,7 +178,7 @@ class Money implements \Serializable */ public function getCurrency(int $decimals = 2) : string { - return ($position === 0 ? $smbol : '') . $this->getAmount($decimals, $thousands, $decimal) . ($position === 1 ? $smbol : ''); + return ($this->position === 0 ? $this->symbol : '') . $this->getAmount($decimals) . ($this->position === 1 ? $this->symbol : ''); } /** @@ -199,6 +219,8 @@ class Money implements \Serializable $this->value += $value; } elseif ($value instanceof Money) { $this->value += $value->getInt(); + } else { + throw new \InvalidArgumentException(); } return $this; @@ -235,8 +257,11 @@ class Money implements \Serializable $this->value -= $value; } elseif ($value instanceof Money) { $this->value -= $value->getInt(); + } else { + throw new \InvalidArgumentException(); } + return $this; } diff --git a/Log/FileLogger.php b/Log/FileLogger.php index 93a32da8a..15e5c317f 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -317,7 +317,7 @@ class FileLogger implements LoggerInterface $this->fp = false; } - if ($this->verbose || php_sapi_name() === 'cli') { + if ($this->verbose) { echo $message, "\n"; } } diff --git a/Math/Finance/FinanceFormulas.php b/Math/Finance/FinanceFormulas.php index 8dac877a9..260b9010e 100644 --- a/Math/Finance/FinanceFormulas.php +++ b/Math/Finance/FinanceFormulas.php @@ -34,7 +34,7 @@ class FinanceFormulas /** * Annual Percentage Yield * - * @latex APY = \left(1+ \frac{r}{n}\right)^{n}-1 + * @latex APY = \left(1+ \frac{r}{n}\right)^{n}-1 * * @param float $r Stated annual interest rate * @param int $n number of times compounded @@ -52,7 +52,7 @@ class FinanceFormulas /** * Annual Percentage Yield * - * @latex r = \left(\left(APY + 1\right)^{\frac{1}{n}} - 1\right) \cdot n + * @latex r = \left(\left(APY + 1\right)^{\frac{1}{n}} - 1\right) \cdot n * * @param float $apy Annual percentage yield * @param int $n Number of times compounded @@ -437,7 +437,7 @@ class FinanceFormulas */ public static function getPeriodsOfPVAD(float $PV, float $P, float $r) : int { - return (int) round((($PV - $P) / $P * $r - 1) / log(1 + $r) + 1); + return (int) round(-(log(-($PV - $P) / $P * $r + 1) / log(1 + $r) - 1)); } /** @@ -572,6 +572,40 @@ class FinanceFormulas return $P * (pow(1 + $r, $n) - 1); } + /** + * Principal of compound interest + * + * @param float $C Compound interest + * @param float $r Rate per period + * @param int $n Number of periods + * + * @return float + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getPrincipalOfCompundInterest(float $C, float $r, int $n) : float + { + return $C / (pow(1 + $r, $n) - 1); + } + + /** + * Principal of compound interest + * + * @param float $P Principal + * @param float $C Compound interest + * @param float $r Rate per period + * + * @return float + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getPeriodsOfCompundInterest(float $P, float $C, float $r) : float + { + return log($C / $P + 1) / log(1 + $r); + } + /** * Continuous Compounding * @@ -589,6 +623,57 @@ class FinanceFormulas return $P * exp($r * $t); } + /** + * Continuous Compounding + * + * @param float $C Compounding + * @param float $r Rate per period + * @param int $t Time + * + * @return float + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getPrincipalOfContinuousCompounding(float $C, float $r, int $t) : float + { + return $C / exp($r * $t); + } + + /** + * Continuous Compounding + * + * @param float $P Principal + * @param float $C Compounding + * @param float $r Rate per period + * + * @return float + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getPeriodsOfContinuousCompounding(float $P, float $C, float $r) : float + { + return log($C / $P) / $r; + } + + /** + * Continuous Compounding + * + * @param float $P Principal + * @param float $C Compounding + * @param float $t Time + * + * @return float + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getRateOfContinuousCompounding(float $P, float $C, float $t) : float + { + return log($C / $P) / $t; + } + /** * Current Ratio * diff --git a/Uri/Http.php b/Uri/Http.php index 7c9bf561e..d4756a623 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -204,7 +204,7 @@ class Http implements UriInterface */ public function getRootPath() : string { - return $this->rootPath ?? ''; + return $this->rootPath; } /** diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 89b0ed548..9e2d70d7d 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -116,7 +116,7 @@ class UriFactory } } - return success; + return $success; } /** diff --git a/Utils/Parser/Markdown/Markdown.php b/Utils/Parser/Markdown/Markdown.php index 2b79709c2..5615ea09c 100644 --- a/Utils/Parser/Markdown/Markdown.php +++ b/Utils/Parser/Markdown/Markdown.php @@ -82,10 +82,12 @@ class Markdown public function parse(string $raw) : string { - $raw = $this->cleanup($raw); + /*$raw = $this->cleanup($raw); $lines = explode("\n", $raw); - return trim($this->parseLines($lines), " \n"); + return trim($this->parseLines($lines), " \n");*/ + + return $raw; } private function cleanup(string $raw) : string