Minor debugging fixes

This commit is contained in:
Dennis Eichhorn 2016-11-23 23:46:55 +01:00
parent 3ec569fa9e
commit baeb32b51e
7 changed files with 123 additions and 11 deletions

View File

@ -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 <d.eichhorn@oms.com>
*/
public function setTemperatur(string $temperature)
public function setTemperature(string $temperature)
{
$this->temperature = $temperature;
}

View File

@ -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 <d.eichhorn@oms.com>
*/
@ -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;
}

View File

@ -317,7 +317,7 @@ class FileLogger implements LoggerInterface
$this->fp = false;
}
if ($this->verbose || php_sapi_name() === 'cli') {
if ($this->verbose) {
echo $message, "\n";
}
}

View File

@ -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
*

View File

@ -204,7 +204,7 @@ class Http implements UriInterface
*/
public function getRootPath() : string
{
return $this->rootPath ?? '';
return $this->rootPath;
}
/**

View File

@ -116,7 +116,7 @@ class UriFactory
}
}
return success;
return $success;
}
/**

View File

@ -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