Skip to content
Code-Schnipsel Gruppen Projekte
Bestätigt Commit c35fd67f erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

refactor: code style

Übergeordneter 7ee1b0e6
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
Dieser Diff ist reduziert.
......@@ -8,6 +8,9 @@
use QUI;
use function is_numeric;
use function round;
/**
* Class CalculationValue
* - represent a number for the calculations
......@@ -19,7 +22,7 @@ class CalculationValue
/**
* @var QUI\ERP\Currency\Currency
*/
protected $Currency;
protected QUI\ERP\Currency\Currency $Currency;
/**
* @var int|string
......@@ -35,19 +38,19 @@ class CalculationValue
* CalculationValue constructor.
*
* @param $number
* @param QUI\ERP\Currency\Currency $Currency
* @param QUI\ERP\Currency\Currency|null $Currency
* @param int|bool $precision - The optional number of decimal digits to round to.
*/
public function __construct($number, $Currency = null, $precision = false)
public function __construct($number, QUI\ERP\Currency\Currency $Currency = null, $precision = false)
{
if (!\is_numeric($number)) {
if (!is_numeric($number)) {
return;
}
$this->number = $number;
// precision
if (\is_numeric($precision)) {
if (is_numeric($precision)) {
$this->precision = $precision;
} else {
$this->precision = QUI\ERP\Defaults::getPrecision();
......@@ -69,7 +72,7 @@ public function __construct($number, $Currency = null, $precision = false)
* @param bool $precision
* @return CalculationValue
*/
public function precision($precision = false)
public function precision(bool $precision = false): CalculationValue
{
if ($precision === false) {
return $this;
......@@ -88,7 +91,7 @@ public function precision($precision = false)
* @param null|QUI\Locale $Locale - optional, Locale object for the formatting
* @return string
*/
public function formatted($Locale = null)
public function formatted(QUI\Locale $Locale = null): string
{
return $this->Currency->format($this->number, $Locale);
}
......@@ -96,10 +99,10 @@ public function formatted($Locale = null)
/**
* Return the un-formatted number
*
* @return int|string
* @return float
*/
public function get()
public function get(): float
{
return \round($this->number, $this->precision);
return round($this->number, $this->precision);
}
}
......@@ -20,23 +20,23 @@ class CalculationVatValue extends CalculationValue
/**
* @var string
*/
protected $text = '';
protected string $text = '';
/**
* @var int
*/
protected $vat;
protected int $vat;
/**
* CalculationValue constructor.
*
* @param int|float|double $number
* @param int|float $number
* @param string $text
* @param int $vat
* @param QUI\ERP\Currency\Currency $Currency
* @param QUI\ERP\Currency\Currency|null $Currency
* @param int|bool $precision - The optional number of decimal digits to round to.
*/
public function __construct($number, $text, $vat, $Currency = null, $precision = false)
public function __construct($number, $text, $vat, QUI\ERP\Currency\Currency $Currency = null, $precision = false)
{
parent::__construct($number, $Currency, $precision);
......@@ -49,7 +49,7 @@ public function __construct($number, $text, $vat, $Currency = null, $precision =
*
* @return string
*/
public function getTitle()
public function getTitle(): string
{
return $this->text;
}
......@@ -59,7 +59,7 @@ public function getTitle()
*
* @return int
*/
public function getVat()
public function getVat(): int
{
return $this->vat;
}
......
......@@ -9,6 +9,8 @@
use QUI;
use QUI\ERP\Exception;
use function is_array;
/**
* Class Calculations
*
......@@ -19,17 +21,17 @@ class Calculations
/**
* @var array
*/
protected $attributes = [];
protected array $attributes = [];
/**
* @var Article[]
*/
protected $articles = [];
protected array $articles = [];
/**
* @var QUI\ERP\Currency\Currency
*/
protected $Currency;
protected QUI\ERP\Currency\Currency $Currency;
/**
* Calculations constructor.
......@@ -37,7 +39,7 @@ class Calculations
* @param array $attributes - calculation array
* @param array $articles - list of articles
*
* @throws \QUI\ERP\Exception
* @throws Exception
*/
public function __construct($attributes, $articles = [])
{
......@@ -69,7 +71,7 @@ public function __construct($attributes, $articles = [])
$this->Currency = QUI\ERP\Defaults::getCurrency();
}
if (\is_array($articles)) {
if (is_array($articles)) {
foreach ($articles as $Article) {
if ($Article instanceof Article) {
$this->articles[] = $Article;
......@@ -83,7 +85,7 @@ public function __construct($attributes, $articles = [])
*
* @return CalculationValue
*/
public function getSum()
public function getSum(): CalculationValue
{
return new CalculationValue(
$this->attributes['sum'],
......@@ -97,7 +99,7 @@ public function getSum()
*
* @return CalculationValue
*/
public function getSubSum()
public function getSubSum(): CalculationValue
{
return new CalculationValue(
$this->attributes['subSum'],
......@@ -111,7 +113,7 @@ public function getSubSum()
*
* @return CalculationValue
*/
public function getNettoSum()
public function getNettoSum(): CalculationValue
{
return new CalculationValue(
$this->attributes['nettoSum'],
......@@ -125,7 +127,7 @@ public function getNettoSum()
*
* @return CalculationValue
*/
public function getNettoSubSum()
public function getNettoSubSum(): CalculationValue
{
return new CalculationValue(
$this->attributes['nettoSubSum'],
......@@ -141,12 +143,12 @@ public function getNettoSubSum()
*
* @return CalculationValue
*/
public function getVatSum()
public function getVatSum(): CalculationValue
{
$sum = 0;
$vat = $this->attributes['vatArray'];
foreach ($vat as $pc => $data) {
foreach ($vat as $data) {
$sum = $sum + $data['sum'];
}
......@@ -172,7 +174,7 @@ public function getVatArray()
*
* @return CalculationVatValue[]
*/
public function getVat()
public function getVat(): array
{
$result = [];
......@@ -194,7 +196,7 @@ public function getVat()
/**
* @return Article[]
*/
public function getArticles()
public function getArticles(): array
{
return $this->articles;
}
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren