From f4c3e8c88278c7305df25ca94357c9cb95e643aa Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 26 Jun 2021 14:38:08 +0200 Subject: [PATCH] fix phpstan/phpcs --- Controller/ApiController.php | 8 +- Models/ClientAttributeType.php | 12 +- Models/ClientAttributeTypeL11n.php | 4 +- Models/ClientAttributeValue.php | 7 + Theme/Backend/Lang/Navigation.en.lang.php | 6 +- Theme/Backend/client-analysis.tpl.php | 274 ++++++++++----------- Theme/Backend/client-profile-items.tpl.php | 14 +- composer.json | 2 +- 8 files changed, 165 insertions(+), 162 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index fe64d4b..d9c6a0b 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -202,10 +202,10 @@ final class ApiController extends Controller */ private function createClientAttributeFromRequest(RequestAbstract $request) : ClientAttribute { - $attribute = new ClientAttribute(); - $attribute->client = (int) $request->getData('client'); - $attribute->type = new NullClientAttributeType((int) $request->getData('type')); - $attribute->value = new NullClientAttributeValue((int) $request->getData('value')); + $attribute = new ClientAttribute(); + $attribute->client = (int) $request->getData('client'); + $attribute->type = new NullClientAttributeType((int) $request->getData('type')); + $attribute->value = new NullClientAttributeValue((int) $request->getData('value')); return $attribute; } diff --git a/Models/ClientAttributeType.php b/Models/ClientAttributeType.php index b606255..0b12f73 100755 --- a/Models/ClientAttributeType.php +++ b/Models/ClientAttributeType.php @@ -68,9 +68,7 @@ class ClientAttributeType implements \JsonSerializable, ArrayableInterface * * @var string | ClientAttributeTypeL11n */ - protected string | - - ClientAttributeTypeL11n $l11n; + protected string|ClientAttributeTypeL11n $l11n; /** * Possible default attribute values @@ -113,16 +111,16 @@ class ClientAttributeType implements \JsonSerializable, ArrayableInterface * * @since 1.0.0 */ - public function setL11n($l11n, string $lang = ISO639x1Enum::_EN) : void + public function setL11n(string|ClientAttributeTypeL11n $l11n, string $lang = ISO639x1Enum::_EN) : void { if ($l11n instanceof ClientAttributeTypeL11n) { $this->l11n = $l11n; - } elseif (\is_string($l11n)) { + } elseif ($this->l11n instanceof ClientAttributeTypeL11n) { + $this->l11n->title = $l11n; + } else { $this->l11n = new ClientAttributeTypeL11n(); $this->l11n->title = $l11n; $this->l11n->setLanguage($lang); - } elseif ($this->l11n instanceof ClientAttributeTypeL11n && \is_string($l11n)) { - $this->l11n->title = $l11n; } } diff --git a/Models/ClientAttributeTypeL11n.php b/Models/ClientAttributeTypeL11n.php index 27fb954..e0b65b0 100755 --- a/Models/ClientAttributeTypeL11n.php +++ b/Models/ClientAttributeTypeL11n.php @@ -41,9 +41,7 @@ class ClientAttributeTypeL11n implements \JsonSerializable, ArrayableInterface * @var int|ClientAttributeType * @since 1.0.0 */ - protected int | - -ClientAttributeType $type = 0; + protected int|ClientAttributeType $type = 0; /** * Language. diff --git a/Models/ClientAttributeValue.php b/Models/ClientAttributeValue.php index 1712154..d6c0418 100755 --- a/Models/ClientAttributeValue.php +++ b/Models/ClientAttributeValue.php @@ -153,6 +153,13 @@ class ClientAttributeValue implements \JsonSerializable, ArrayableInterface } } + /** + * Get value + * + * @return null|int|string|float|\DateTimeInterface + * + * @since 1.0.0 + */ public function getValue() : mixed { if (!empty($this->valueStr)) { diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index 05bd646..64e575b 100755 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -13,7 +13,7 @@ declare(strict_types=1); return ['Navigation' => [ - 'Client' => 'Client', - 'Region' => 'Region', - 'SalesRep' => 'SalesRep', + 'Client' => 'Client', + 'Region' => 'Region', + 'SalesRep' => 'SalesRep', ]]; diff --git a/Theme/Backend/client-analysis.tpl.php b/Theme/Backend/client-analysis.tpl.php index 961ec8d..79cd8eb 100755 --- a/Theme/Backend/client-analysis.tpl.php +++ b/Theme/Backend/client-analysis.tpl.php @@ -37,11 +37,11 @@ echo $this->getData('nav')->render();
request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
-
+
-
-
getHtml('Filter'); ?>
+ +
getHtml('Filter'); ?>
@@ -89,23 +89,23 @@ echo $this->getData('nav')->render();
-
-
-
+ +
+
request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
-
+
-
- Sales / Customers - Monthly - -
+
+ Sales / Customers - Monthly + +
getData('monthlySalesCustomer'); ?>
- getData('nav')->render(); ] }, "options": { - "title": { - "display": false, - "text": "Sales / Customers" - }, + "title": { + "display": false, + "text": "Sales / Customers" + }, "scales": { "yAxes": [ { @@ -184,42 +184,42 @@ echo $this->getData('nav')->render(); } } }'> -
- - -
- - - - - - - -
Month - Sales - Customer count -
- getCurrency(); ?> - - -
Total - getCurrency(); ?> - -
-
-
-
-
-
+
+ + +
+ + + + + + + +
Month + Sales + Customer count +
+ getCurrency(); ?> + + +
Total + getCurrency(); ?> + +
+
+
+
+ +
@@ -337,15 +337,15 @@ echo $this->getData('nav')->render();
-
+
Customers per Region - Current
- getData('currentCustomerRegion'); ?> + getData('currentCustomerRegion'); ?>
- getData('nav')->render(); }] }, "options": { - "title": { - "display": false, - "text": "Customers per Region - Currently" - } - } + "title": { + "display": false, + "text": "Customers per Region - Currently" + } + } }'>
@@ -386,27 +386,27 @@ echo $this->getData('nav')->render();
- - - - $values) : $sum += $values; ?> - - - + + + $values) : $sum += $values; ?> + + +
Region - Customer count -
- - -
Total - +
Region + Customer count +
+ + +
Total +
-
-
+ +
@@ -605,15 +605,15 @@ echo $this->getData('nav')->render();
-
+
Customers per Rep - Current
- getData('currentCustomersRep'); ?> + getData('currentCustomersRep'); ?>
- getData('nav')->render(); ] }, "options": { - "title": { - "display": false, - "text": "Customers per rep" - } + "title": { + "display": false, + "text": "Customers per rep" + } } }'> @@ -680,8 +680,8 @@ echo $this->getData('nav')->render();
- -
+ +
@@ -717,15 +717,15 @@ echo $this->getData('nav')->render();
-
+
Customers per Country - Current
- getData('currentCustomersCountry'); ?> + getData('currentCustomersCountry'); ?>
- getData('nav')->render(); ] }, "options": { - "title": { - "display": false, - "text": "Customers per country" - } + "title": { + "display": false, + "text": "Customers per country" + } } }'> @@ -773,27 +773,27 @@ echo $this->getData('nav')->render();
- - - - $values) : $sum += $values['customers']; ?> - - - + + + $values) : $sum += $values['customers']; ?> + + +
Country - Customer count -
- - -
Total - +
Country + Customer count +
+ + +
Total +
- -
+ +
@@ -831,13 +831,13 @@ echo $this->getData('nav')->render();
-
+
Customer per Attribute - Current
- getData('customerGroups'); ?> + getData('customerGroups'); ?>
@@ -847,7 +847,7 @@ echo $this->getData('nav')->render();
- getData('nav')->render(); }] }, "options": { - "title": { - "display": false, - "text": "Customers per group" - } - } + "title": { + "display": false, + "text": "Customers per group" + } + } }'>
@@ -896,27 +896,27 @@ echo $this->getData('nav')->render();
- - - - $values) : $sum += $values['customers']; ?> - - - + + + $values) : $sum += $values['customers']; ?> + + +
Groups - Customer count -
- - -
Total - +
Groups + Customer count +
+ + +
Total +
- -
+ +
@@ -1218,7 +1218,7 @@ echo $this->getData('nav')->render(); request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>>
-
+
@@ -2283,7 +2283,7 @@ echo $this->getData('nav')->render(); request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>>
-
+
diff --git a/Theme/Backend/client-profile-items.tpl.php b/Theme/Backend/client-profile-items.tpl.php index af8053a..05900c3 100755 --- a/Theme/Backend/client-profile-items.tpl.php +++ b/Theme/Backend/client-profile-items.tpl.php @@ -128,14 +128,14 @@ $items = $this->getData('items') ?? []; $value) : - if ($value->itemNumber === '') { - continue; - } + $count = 0; + foreach ($items as $key => $value) : + if ($value->itemNumber === '') { + continue; + } - ++$count; - $url = UriFactory::build('{/prefix}sales/item/profile?{?}&id=' . $value->getId()); + ++$count; + $url = UriFactory::build('{/prefix}sales/item/profile?{?}&id=' . $value->getId()); ?>