diff --git a/README.md b/README.md
index 03cfff188..9f99969c7 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,7 @@ Ce programme est distribué avec une [licence propriétaire](LICENSE.md) et une
[](https://www.php.net)
[](https://www.mysql.com)
[](https://httpd.apache.org)
+[](https://www.jetbrains.com/phpstorm)
## Qualité du code
diff --git a/composer.lock b/composer.lock
index 7344c3265..7ba5b3913 100644
--- a/composer.lock
+++ b/composer.lock
@@ -11865,16 +11865,16 @@
},
{
"name": "spatie/array-to-xml",
- "version": "3.2.3",
+ "version": "3.3.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/array-to-xml.git",
- "reference": "c95fd4db94ec199f798d4b5b4a81757bd20d88ab"
+ "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/c95fd4db94ec199f798d4b5b4a81757bd20d88ab",
- "reference": "c95fd4db94ec199f798d4b5b4a81757bd20d88ab",
+ "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/f56b220fe2db1ade4c88098d83413ebdfc3bf876",
+ "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876",
"shasum": ""
},
"require": {
@@ -11887,6 +11887,11 @@
"spatie/pest-plugin-snapshots": "^1.1"
},
"type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.x-dev"
+ }
+ },
"autoload": {
"psr-4": {
"Spatie\\ArrayToXml\\": "src"
@@ -11912,7 +11917,7 @@
"xml"
],
"support": {
- "source": "https://github.com/spatie/array-to-xml/tree/3.2.3"
+ "source": "https://github.com/spatie/array-to-xml/tree/3.3.0"
},
"funding": [
{
@@ -11924,7 +11929,7 @@
"type": "github"
}
],
- "time": "2024-02-07T10:39:02+00:00"
+ "time": "2024-05-01T10:20:27+00:00"
},
{
"name": "symfony/browser-kit",
@@ -12503,16 +12508,16 @@
},
{
"name": "vimeo/psalm",
- "version": "5.23.1",
+ "version": "5.24.0",
"source": {
"type": "git",
"url": "https://github.com/vimeo/psalm.git",
- "reference": "8471a896ccea3526b26d082f4461eeea467f10a4"
+ "reference": "462c80e31c34e58cc4f750c656be3927e80e550e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/vimeo/psalm/zipball/8471a896ccea3526b26d082f4461eeea467f10a4",
- "reference": "8471a896ccea3526b26d082f4461eeea467f10a4",
+ "url": "https://api.github.com/repos/vimeo/psalm/zipball/462c80e31c34e58cc4f750c656be3927e80e550e",
+ "reference": "462c80e31c34e58cc4f750c656be3927e80e550e",
"shasum": ""
},
"require": {
@@ -12609,7 +12614,7 @@
"issues": "https://github.com/vimeo/psalm/issues",
"source": "https://github.com/vimeo/psalm"
},
- "time": "2024-03-11T20:33:46+00:00"
+ "time": "2024-05-01T19:32:08+00:00"
},
{
"name": "vincentlanglet/twig-cs-fixer",
diff --git a/public/js/extensions/bootstrap-table-extensions.js b/public/js/extensions/bootstrap-table-extensions.js
index ed7e8abd1..83eaa4f9f 100644
--- a/public/js/extensions/bootstrap-table-extensions.js
+++ b/public/js/extensions/bootstrap-table-extensions.js
@@ -44,7 +44,7 @@ function loadingTemplate(message) {
}
/**
- * JQuery extension for Bootstrap tables, rows and cells.
+ * JQuery extension for Bootstrap tables rows and cells.
*/
(function ($) {
'use strict';
@@ -204,7 +204,7 @@ function loadingTemplate(message) {
// data?
if (data.length !== 0) {
- // hide empty data message
+ // hide the empty data message
$this.hideCustomViewMessage();
const params = $this.getParameters();
const selector = '.custom-view-actions:eq(%index%)';
@@ -230,7 +230,7 @@ function loadingTemplate(message) {
}
$this.highlight();
} else {
- // show empty data message
+ // show the empty data message
$this.showCustomViewMessage();
}
$this.saveParameters();
@@ -932,8 +932,26 @@ function loadingTemplate(message) {
options = options ? options : $this.getOptions();
pageNumber = pageNumber || options.pageNumber;
const text = $('#modal-page').data('page');
- return text.replace('%page%', pageNumber)
- .replace('%pages%', options.totalPages);
+ return text.replace('%page%', $.formatInt(pageNumber))
+ .replace('%pages%', $.formatInt(options.totalPages));
+ },
+
+ /**
+ * Format the records range.
+ *
+ * @param {Options} [options] the options to get pages from.
+ * @param {number} [pageNumber] the optional current page.
+ */
+ formatRecords: function (options, pageNumber) {
+ const $this = $(this);
+ options = options ? options : $this.getOptions();
+ pageNumber = pageNumber || options.pageNumber;
+ const pageSize = options.pageSize;
+ const record = Math.max(1 + (pageNumber - 1) * pageSize, 1);
+ const records = Math.min(record + pageSize - 1, options.totalRows);
+ const text = $('#modal-page').data('record');
+ return text.replace('%record%', $.formatInt(record))
+ .replace('%records%', $.formatInt(records));
},
/**
@@ -948,7 +966,8 @@ function loadingTemplate(message) {
const $this = $(this);
const $range = $('#page-range');
- const $label = $('#page-label');
+ const $labelRecord = $('#page-record');
+ const $labelLabel = $('#page-label');
const $button = $('#page-button');
$dialog.on('keydown', function (e) {
if (e.key === 'Enter') {
@@ -982,9 +1001,12 @@ function loadingTemplate(message) {
}
$range.on('input', function () {
- const title = $this.formatPages($range.data('options'), $range.intVal());
+ const value = $range.intVal();
+ const title = $this.formatPages($range.data('options'), value);
+ const records = $this.formatRecords($range.data('options'), value);
$range.attr('title', title);
- $label.text(title);
+ $labelLabel.text(title);
+ $labelRecord.text(records);
});
$button.on('click', function () {
diff --git a/public/js/extensions/jquery-extensions.js b/public/js/extensions/jquery-extensions.js
index bb8b8cdd3..eb4c53e9c 100644
--- a/public/js/extensions/jquery-extensions.js
+++ b/public/js/extensions/jquery-extensions.js
@@ -48,10 +48,10 @@
},
/**
- * Returns if the given data is a boolean.
+ * Returns if the given data is boolean.
*
* @param {any} data - The data to evaluate.
- * @return {boolean} true if a boolean.
+ * @return {boolean} true if boolean.
*/
isBoolean: function (data) {
return typeof data === 'boolean';
@@ -102,7 +102,7 @@
},
/**
- * Format a value with 0 decimal and grouping separator.
+ * Format a value with 0 decimal and the grouping separator.
*
* @param {number} value - the value to format.
* @returns {string} the formatted value.
@@ -145,7 +145,7 @@
$.fn.extend({
/**
- * Check if the element is visible into area of the browser window.
+ * Check if the element is visible into the area of the browser window.
*
* @param {int} bottomMargin - The bottom margin (default to 50).
* @return {boolean} true if visible, false if not.
@@ -395,7 +395,7 @@
return false;
}
- // check type (copied from accept method)
+ // check the type (copied from accept method)
let type = $(this).attr('accept') || false;
if (type) {
type = type.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g, '\\$&')
@@ -520,7 +520,7 @@
},
/**
- * Returns if the given attribute exist and is not false or null.
+ * Returns if the given attribute exists and is not false or null.
*
* @param {string} name - the attribute name to check existence for.
* @return {boolean} true if the attribute name is set.
diff --git a/src/Controller/AbstractController.php b/src/Controller/AbstractController.php
index 443950fef..56afe8689 100644
--- a/src/Controller/AbstractController.php
+++ b/src/Controller/AbstractController.php
@@ -79,16 +79,6 @@ public function getAddressFrom(): Address
return new Address($email, $name);
}
- /**
- * Gets the application service.
- *
- * @throws \LogicException if the service can not be found
- */
- public function getApplication(): ApplicationService
- {
- return $this->getUserService()->getApplication();
- }
-
/**
* Gets the application name and version.
*/
@@ -105,18 +95,28 @@ public function getApplicationOwnerUrl(): string
return $this->getParameterString('app_owner_url');
}
+ /**
+ * Gets the application service.
+ *
+ * @throws \LogicException if the service cannot be found
+ */
+ public function getApplicationService(): ApplicationService
+ {
+ return $this->getUserService()->getApplication();
+ }
+
/**
* Gets the minimum margin, in percent, for a calculation.
*/
public function getMinMargin(): float
{
- return $this->getApplication()->getMinMargin();
+ return $this->getApplicationService()->getMinMargin();
}
/**
* Gets the request stack.
*
- * @throws \LogicException if the service can not be found
+ * @throws \LogicException if the service cannot be found
*
* @psalm-suppress MixedAssignment
* @psalm-suppress MixedReturnStatement
@@ -137,17 +137,18 @@ public function getRequestStack(): RequestStack
public static function getSubscribedServices(): array
{
- return \array_merge(parent::getSubscribedServices(), [
+ return [
+ ...parent::getSubscribedServices(),
UserService::class,
TranslatorInterface::class,
UrlGeneratorService::class,
- ]);
+ ];
}
/**
* Gets the translator.
*
- * @throws \LogicException if the service can not be found
+ * @throws \LogicException if the service cannot be found
*/
public function getTranslator(): TranslatorInterface
{
@@ -165,7 +166,7 @@ public function getTranslator(): TranslatorInterface
/**
* Gets the URL generator service.
*
- * @throws \LogicException if the service can not be found
+ * @throws \LogicException if the service cannot be found
*/
public function getUrlGenerator(): UrlGeneratorService
{
@@ -193,7 +194,7 @@ public function getUserIdentifier(): ?string
/**
* Gets the user service.
*
- * @throws \LogicException if the service can not be found
+ * @throws \LogicException if the service cannot be found
*/
public function getUserService(): UserService
{
@@ -209,7 +210,7 @@ public function getUserService(): UserService
}
/**
- * Display a message, if not empty; and redirect to the home page.
+ * Display a message, if not empty, and redirect to the home page.
*
* If the request is not null, and the caller parameter is set, redirect to it.
*/
@@ -316,7 +317,7 @@ protected function jsonException(\Exception $e, ?string $message = null): JsonRe
}
/**
- * Returns a Json response with false as result.
+ * Returns a Json response with false as the result.
*
* @param array $data the data to merge within the response
*/
@@ -326,7 +327,7 @@ protected function jsonFalse(array $data = []): JsonResponse
}
/**
- * Returns a Json response with true as result.
+ * Returns a Json response with true as the result.
*
* @param array $data the data to merge within the response
*/
diff --git a/src/Controller/AbstractEntityController.php b/src/Controller/AbstractEntityController.php
index 30d30f3bc..49dc95c60 100644
--- a/src/Controller/AbstractEntityController.php
+++ b/src/Controller/AbstractEntityController.php
@@ -130,7 +130,7 @@ protected function deleteEntity(
}
/**
- * This function delete the given entity from the database.
+ * This function deletes the given entity from the database.
*
* @psalm-param TEntity $item
*/
@@ -286,9 +286,9 @@ protected function renderWordDocument(WordDocument $doc, bool $inline = true, st
}
/**
- * This function save the given entity to the database.
+ * This function saves the given entity to the database.
*
- * Derived class can update entity before it is saved to the database.
+ * Derived class can update the entity before it is saved to the database.
*
* @psalm-param TEntity $item
*/
diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php
index 2dd72ec54..2219bc838 100644
--- a/src/Controller/AdminController.php
+++ b/src/Controller/AdminController.php
@@ -64,7 +64,7 @@ public function clearCache(
$form = $this->createForm(FormType::class);
if ($this->handleRequestForm($request, $form)) {
$this->getUserService()->clearCache();
- $this->getApplication()->clearCache();
+ $this->getApplicationService()->clearCache();
try {
if ($service->clear()) {
@@ -130,7 +130,7 @@ public function dumpSql(KernelInterface $kernel): Response
#[GetPost(path: '/parameters', name: 'admin_parameters')]
public function parameters(Request $request): Response
{
- $application = $this->getApplication();
+ $application = $this->getApplicationService();
$data = $application->getProperties();
$form = $this->createForm(ApplicationParametersType::class, $data);
if ($this->handleRequestForm($request, $form)) {
@@ -156,7 +156,7 @@ public function parameters(Request $request): Response
#[GetPost(path: '/rights/admin', name: 'admin_rights_admin')]
public function rightsAdmin(Request $request, RoleBuilderService $service): Response
{
- $application = $this->getApplication();
+ $application = $this->getApplicationService();
$roleName = RoleInterface::ROLE_ADMIN;
$rights = $application->getAdminRights();
$default = $service->getRoleAdmin();
@@ -171,7 +171,7 @@ public function rightsAdmin(Request $request, RoleBuilderService $service): Resp
#[GetPost(path: '/rights/user', name: 'admin_rights_user')]
public function rightsUser(Request $request, RoleBuilderService $service): Response
{
- $application = $this->getApplication();
+ $application = $this->getApplicationService();
$roleName = RoleInterface::ROLE_USER;
$rights = $application->getUserRights();
$default = $service->getRoleUser();
diff --git a/src/Controller/AjaxCalculationController.php b/src/Controller/AjaxCalculationController.php
index 90122aeb0..52ffc78d1 100644
--- a/src/Controller/AjaxCalculationController.php
+++ b/src/Controller/AjaxCalculationController.php
@@ -67,6 +67,8 @@ public function renderTaskDialog(TaskRepository $repository): JsonResponse
/**
* Update the total of a calculation.
+ *
+ * @throws \Doctrine\ORM\Exception\ORMException
*/
#[Post(path: '/update', name: 'ajax_update')]
public function update(Request $request, CalculationService $service, LoggerInterface $logger): JsonResponse
diff --git a/src/Controller/AjaxTranslateController.php b/src/Controller/AjaxTranslateController.php
index 51db2835b..6275998c1 100644
--- a/src/Controller/AjaxTranslateController.php
+++ b/src/Controller/AjaxTranslateController.php
@@ -40,7 +40,7 @@ public function __construct(private readonly TranslatorFactory $factory)
}
/**
- * Identifies the language of a piece of text.
+ * Identifies the language for a piece of text.
*
* @throws ServiceNotFoundException if the service is not found
*/
diff --git a/src/Controller/CalculationArchiveController.php b/src/Controller/CalculationArchiveController.php
index 9e22b2294..b00661224 100644
--- a/src/Controller/CalculationArchiveController.php
+++ b/src/Controller/CalculationArchiveController.php
@@ -48,7 +48,7 @@ public function invoke(Request $request, CalculationArchiveService $service): Re
}
$query = $service->createQuery();
- $application = $this->getApplication();
+ $application = $this->getApplicationService();
$form = $this->createQueryForm($service, $query);
if ($this->handleRequestForm($request, $form)) {
$service->saveQuery($query);
diff --git a/src/Controller/CalculationBelowController.php b/src/Controller/CalculationBelowController.php
index 67e74dea0..7b8c9a08b 100644
--- a/src/Controller/CalculationBelowController.php
+++ b/src/Controller/CalculationBelowController.php
@@ -44,7 +44,7 @@ class CalculationBelowController extends AbstractController
/**
* Export the calculations to a Spreadsheet document.
*
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the report can not be rendered
+ * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the report cannot be rendered
* @throws \Doctrine\ORM\Exception\ORMException
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
diff --git a/src/Controller/CalculationController.php b/src/Controller/CalculationController.php
index a6eba495e..a5e6c799f 100644
--- a/src/Controller/CalculationController.php
+++ b/src/Controller/CalculationController.php
@@ -65,7 +65,7 @@ public function __construct(CalculationRepository $repository, private readonly
public function add(Request $request): Response
{
$item = new Calculation();
- $application = $this->getApplication();
+ $application = $this->getApplicationService();
$state = $application->getDefaultState();
if ($state instanceof CalculationState) {
$item->setState($state);
@@ -88,7 +88,7 @@ public function add(Request $request): Response
public function clone(Request $request, Calculation $item): Response
{
$description = $this->trans('common.clone_description', ['%description%' => $item->getDescription()]);
- $state = $this->getApplication()->getDefaultState();
+ $state = $this->getApplicationService()->getDefaultState();
$clone = $item->clone($state, $description);
$parameters = [
'title' => 'calculation.clone.title',
@@ -293,6 +293,6 @@ private function getQrCode(UrlGeneratorInterface $generator, Calculation $calcul
private function isMarginBelow(Calculation $calculation): bool
{
- return $this->getApplication()->isMarginBelow($calculation);
+ return $this->getApplicationService()->isMarginBelow($calculation);
}
}
diff --git a/src/Controller/CalculationStateController.php b/src/Controller/CalculationStateController.php
index 31d36de03..3b0250c20 100644
--- a/src/Controller/CalculationStateController.php
+++ b/src/Controller/CalculationStateController.php
@@ -178,7 +178,7 @@ public function table(
*/
protected function deleteFromDatabase(EntityInterface $item): void
{
- $this->getApplication()->updateDeletedState($item);
+ $this->getApplicationService()->updateDeletedState($item);
parent::deleteFromDatabase($item);
}
}
diff --git a/src/Controller/CalculationUpdateController.php b/src/Controller/CalculationUpdateController.php
index f8f230521..24cab7999 100644
--- a/src/Controller/CalculationUpdateController.php
+++ b/src/Controller/CalculationUpdateController.php
@@ -28,7 +28,7 @@
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
- * Controller to update overall total of calculations.
+ * Controller to update the overall total of calculations.
*/
#[AsController]
#[Route(path: '/admin')]
@@ -42,7 +42,7 @@ class CalculationUpdateController extends AbstractController
public function update(Request $request, CalculationUpdateService $service): Response
{
$query = $service->createQuery();
- $application = $this->getApplication();
+ $application = $this->getApplicationService();
$form = $this->createQueryForm($query);
if ($this->handleRequestForm($request, $form)) {
$service->saveQuery($query);
diff --git a/src/Controller/CategoryController.php b/src/Controller/CategoryController.php
index 7c0d3936a..655de34ee 100644
--- a/src/Controller/CategoryController.php
+++ b/src/Controller/CategoryController.php
@@ -191,7 +191,7 @@ public function table(
*/
protected function deleteFromDatabase(EntityInterface $item): void
{
- $this->getApplication()->updateDeletedCategory($item);
+ $this->getApplicationService()->updateDeletedCategory($item);
parent::deleteFromDatabase($item);
}
}
diff --git a/src/Controller/GroupController.php b/src/Controller/GroupController.php
index e23a60c54..89818f909 100644
--- a/src/Controller/GroupController.php
+++ b/src/Controller/GroupController.php
@@ -132,8 +132,7 @@ public function excel(): SpreadsheetResponse
{
$entities = $this->getEntities('code');
if ([] === $entities) {
- $message = $this->trans('group.list.empty');
- throw $this->createNotFoundException($message);
+ throw $this->createNotFoundException($this->trans('group.list.empty'));
}
$doc = new GroupsDocument($this, $entities);
@@ -143,7 +142,7 @@ public function excel(): SpreadsheetResponse
/**
* Export the groups to a PDF document.
*
- * @throws NotFoundHttpException if no group is found
+ * @throws NotFoundHttpException
* @throws \Doctrine\ORM\Exception\ORMException
*/
#[Get(path: '/pdf', name: 'group_pdf')]
@@ -151,8 +150,7 @@ public function pdf(): PdfResponse
{
$entities = $this->getEntities('code');
if ([] === $entities) {
- $message = $this->trans('group.list.empty');
- throw $this->createNotFoundException($message);
+ throw $this->createNotFoundException($this->trans('group.list.empty'));
}
$doc = new GroupsReport($this, $entities);
diff --git a/src/Controller/ImportAddressController.php b/src/Controller/ImportAddressController.php
index fdeb7c128..967e36b83 100644
--- a/src/Controller/ImportAddressController.php
+++ b/src/Controller/ImportAddressController.php
@@ -52,7 +52,7 @@ public function invoke(Request $request, SwissPostUpdater $updater): Response
}
return $this->render('admin/import_query.html.twig', [
- 'last_import' => $this->getApplication()->getLastImport(),
+ 'last_import' => $this->getApplicationService()->getLastImport(),
'data_url' => self::DATA_URL,
'form' => $form,
]);
diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php
index 2e5a5e150..31341418f 100644
--- a/src/Controller/IndexController.php
+++ b/src/Controller/IndexController.php
@@ -192,7 +192,7 @@ private function checkAjaxRequest(Request $request): void
*/
private function count($className): int
{
- return $this->manager->getRepository($className)->count([]);
+ return $this->manager->getRepository($className)->count();
}
private function getCalculations(int $maxResults, ?UserInterface $user): array
diff --git a/src/Controller/OpenWeatherController.php b/src/Controller/OpenWeatherController.php
index 23fda9135..f9470b7c7 100644
--- a/src/Controller/OpenWeatherController.php
+++ b/src/Controller/OpenWeatherController.php
@@ -98,7 +98,7 @@ public function __construct(private readonly OpenWeatherService $service)
}
/**
- * Returns current conditions data for a specific location.
+ * Returns the current conditions data for a specific location.
*
* @psalm-api
*/
@@ -143,7 +143,7 @@ public function apiDaily(Request $request): JsonResponse
}
/**
- * Returns 5 days / 3 hours forecast conditions data for a specific location.
+ * Returns 5-days / 3-hour forecast conditions data for a specific location.
*
* @psalm-api
*/
@@ -233,7 +233,7 @@ public function apiSearch(Request $request, UrlGeneratorInterface $generator): J
}
/**
- * Returns current conditions data for a specific location.
+ * Returns the current conditions data for a specific location.
*/
#[Get(path: '/current', name: 'openweather_current')]
public function current(Request $request): Response
diff --git a/src/Controller/ProductController.php b/src/Controller/ProductController.php
index 72647ba1d..328b56eb0 100644
--- a/src/Controller/ProductController.php
+++ b/src/Controller/ProductController.php
@@ -56,7 +56,7 @@ public function __construct(ProductRepository $repository)
public function add(Request $request): Response
{
$item = new Product();
- $category = $this->getApplication()->getDefaultCategory();
+ $category = $this->getApplicationService()->getDefaultCategory();
if ($category instanceof Category) {
$item->setCategory($category);
}
@@ -162,7 +162,7 @@ public function table(
*/
protected function deleteFromDatabase(EntityInterface $item): void
{
- $this->getApplication()->updateDeletedProduct($item);
+ $this->getApplicationService()->updateDeletedProduct($item);
parent::deleteFromDatabase($item);
}
}
diff --git a/src/Controller/ProductUpdateController.php b/src/Controller/ProductUpdateController.php
index fcae43e66..cc99d8323 100644
--- a/src/Controller/ProductUpdateController.php
+++ b/src/Controller/ProductUpdateController.php
@@ -40,7 +40,7 @@ class ProductUpdateController extends AbstractController
public function invoke(Request $request, ProductUpdateService $service): Response
{
$query = $service->createQuery();
- $application = $this->getApplication();
+ $application = $this->getApplicationService();
$form = $this->createQueryForm($service, $query);
if ($this->handleRequestForm($request, $form)) {
$service->saveQuery($query);
diff --git a/src/Controller/ProfileController.php b/src/Controller/ProfileController.php
index 42da9046b..346346087 100644
--- a/src/Controller/ProfileController.php
+++ b/src/Controller/ProfileController.php
@@ -34,7 +34,7 @@
class ProfileController extends AbstractController
{
/**
- * Change password of the current user (if any).
+ * Change the password of the current user (if any).
*/
#[GetPost(path: '/change-password', name: 'user_profile_change_password')]
public function changePassword(Request $request, #[CurrentUser] User $user, EntityManagerInterface $manager): Response
diff --git a/src/Controller/ResetPasswordController.php b/src/Controller/ResetPasswordController.php
index 67f86420e..1bcbde2e8 100644
--- a/src/Controller/ResetPasswordController.php
+++ b/src/Controller/ResetPasswordController.php
@@ -76,7 +76,7 @@ public function checkEmail(): Response
}
/**
- * Display and process form to request a password reset.
+ * Display and process the form to request a password reset.
*/
#[GetPost(path: '', name: self::ROUTE_REQUEST)]
public function request(Request $request, AuthenticationUtils $utils): Response
diff --git a/src/Controller/TaskController.php b/src/Controller/TaskController.php
index 7214eeb58..5fa813151 100644
--- a/src/Controller/TaskController.php
+++ b/src/Controller/TaskController.php
@@ -60,7 +60,7 @@ public function __construct(TaskRepository $repository)
public function add(Request $request): Response
{
$item = new Task();
- $category = $this->getApplication()->getDefaultCategory();
+ $category = $this->getApplicationService()->getDefaultCategory();
if ($category instanceof Category) {
$item->setCategory($category);
}
diff --git a/src/Database/AbstractDatabase.php b/src/Database/AbstractDatabase.php
index 5cd960b8b..f079da920 100644
--- a/src/Database/AbstractDatabase.php
+++ b/src/Database/AbstractDatabase.php
@@ -39,9 +39,11 @@ abstract class AbstractDatabase extends \SQLite3 implements \Stringable
/**
* Instantiates and opens the database.
*
- * @param string $filename Path to the SQLite database, or :memory: to use in-memory database.
- * If filename is an empty string, then a private, temporary on-disk database will be created.
- * This private database will be automatically deleted as soon as the database connection is closed.
+ * @param string $filename Path to the SQLite database, or :memory: to use the in-memory database.
+ * If filename is an empty string, then a private, temporary on-disk database will be
+ * created.
+ * This private database will be automatically deleted as soon as the database
+ * connection is closed.
* @param bool $readonly true open the database for reading only. Note that if the file name
* does not exist, the database is opened with the
* SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE flags.
@@ -180,7 +182,7 @@ public function isTransaction(): bool
* @param string $name the pragma name
* @param mixed|null $value the optional pragma value
*
- * @return bool true if the succeeded; false on failure
+ * @return bool true if succeeded; false on failure
*/
public function pragma(string $name, mixed $value = null): bool
{
diff --git a/src/Database/SwissDatabase.php b/src/Database/SwissDatabase.php
index d96a11317..617b70dbb 100644
--- a/src/Database/SwissDatabase.php
+++ b/src/Database/SwissDatabase.php
@@ -229,7 +229,7 @@ public function findZip(string $zip, int $limit = 25): array
}
/**
- * Gets the records count for all tables.
+ * Gets the record's count for all tables.
*
* @return array{state: int, city: int, street: int}
*/
diff --git a/src/Entity/AbstractProperty.php b/src/Entity/AbstractProperty.php
index 4c65d9b64..3c7b4742c 100644
--- a/src/Entity/AbstractProperty.php
+++ b/src/Entity/AbstractProperty.php
@@ -58,7 +58,7 @@ public function __construct(?string $name = null)
}
/**
- * Gets this property value as an array. Internally the array is decoded from a JSON string.
+ * Gets this property value as an array. Internally, the array is decoded from a JSON string.
*
* @psalm-api
*/
@@ -130,7 +130,7 @@ public function getValue(): ?string
}
/**
- * Sets the property value as an array. Internally the array is encoded as JSON string.
+ * Sets the property value as an array. Internally, the array is encoded as JSON string.
*/
public function setArray(?array $value): static
{
@@ -184,7 +184,7 @@ public function setString(?string $value): static
/**
* Sets the property value.
*
- * This function try first to convert the value to an appropriate type (bool, int, etc...).
+ * This function tries first to convert the value to an appropriate type (bool, int, etc...).
*/
public function setValue(mixed $value): static
{
diff --git a/src/Entity/Calculation.php b/src/Entity/Calculation.php
index 0ecdb3c3f..a9b799177 100644
--- a/src/Entity/Calculation.php
+++ b/src/Entity/Calculation.php
@@ -181,7 +181,7 @@ public function contains(CalculationGroup $group): bool
*/
public function findCategory(Category $category): CalculationCategory
{
- // find group
+ // find the group
/** @var Group $categoryGroup */
$categoryGroup = $category->getGroup();
$group = $this->findGroup($categoryGroup);
@@ -208,7 +208,7 @@ public function findCategory(Category $category): CalculationCategory
*/
public function findGroup(Group $group): CalculationGroup
{
- // find group
+ // find the group
$code = $group->getCode();
foreach ($this->groups as $current) {
if ($code === $current->getCode()) {
@@ -216,7 +216,7 @@ public function findGroup(Group $group): CalculationGroup
}
}
- // create group
+ // create the group
$newGroup = CalculationGroup::create($group);
$this->addGroup($newGroup);
@@ -266,7 +266,7 @@ public function getDisplay(): string
}
/**
- * Gets the duplicates items.
+ * Gets the duplicate items.
*
* Items are duplicate when two or more item descriptions are equal, ignoring case considerations.
*
@@ -547,7 +547,7 @@ public function getStateColor(): ?string
}
/**
- * Get total net. This is total of the groups multiplied by the global margin.
+ * Get total net. This is the total of the groups multiplied by the global margin.
*/
public function getTotalNet(): float
{
@@ -641,7 +641,7 @@ public function isEditable(): bool
/**
* Checks whether the groups are empty (contains no elements).
*
- * @return bool true if the groups is empty, false otherwise
+ * @return bool true if groups are empty, false otherwise
*/
public function isEmpty(): bool
{
@@ -803,7 +803,7 @@ public function setGlobalMargin(float $globalMargin): self
}
/**
- * Sets the items total.
+ * Sets the item's total.
*/
public function setItemsTotal(float $itemsTotal): self
{
@@ -867,7 +867,7 @@ public function sort(): bool
/**
* Update the group and category codes.
*
- * @return int the number of update
+ * @return int the number of updates
*
* @psalm-api
*/
diff --git a/src/Entity/CalculationCategory.php b/src/Entity/CalculationCategory.php
index 159c2c0ef..1bf209008 100644
--- a/src/Entity/CalculationCategory.php
+++ b/src/Entity/CalculationCategory.php
@@ -182,7 +182,7 @@ public function getParentEntity(): ?Calculation
/**
* Checks whether the category is empty (contains no items).
*
- * @return bool true if the groups is empty, false otherwise
+ * @return bool true if groups are empty, false otherwise
*/
public function isEmpty(): bool
{
@@ -265,7 +265,7 @@ public function setGroup(?CalculationGroup $group): self
}
/**
- * Sorts this items by the alphabetical order of descriptions.
+ * Sorts items by the alphabetical order of descriptions.
*
* @return bool true if the order has changed
*/
diff --git a/src/Entity/CalculationGroup.php b/src/Entity/CalculationGroup.php
index c952286fa..337f1f822 100644
--- a/src/Entity/CalculationGroup.php
+++ b/src/Entity/CalculationGroup.php
@@ -206,7 +206,7 @@ public function getTotal(): float
/**
* Checks whether the categories are empty (contains no categories).
*
- * @return bool true if the groups is empty, false otherwise
+ * @return bool true if the groups are empty, false otherwise
*/
public function isEmpty(): bool
{
diff --git a/src/Entity/CalculationItem.php b/src/Entity/CalculationItem.php
index b95ec5ca7..ea6f6c035 100644
--- a/src/Entity/CalculationItem.php
+++ b/src/Entity/CalculationItem.php
@@ -144,7 +144,7 @@ public function getUnit(): ?string
}
/**
- * Returns if the price or the quantity are equal to zero.
+ * Returns if the price or the quantity is equal to zero.
*/
public function isEmpty(): bool
{
diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php
index a452663ce..8ab3bb5b4 100644
--- a/src/Entity/Customer.php
+++ b/src/Entity/Customer.php
@@ -92,7 +92,7 @@ public function getAddress(): ?string
}
/**
- * Get age or null if birthday is null.
+ * Get age or null if the birthday is null.
*/
public function getAge(): ?int
{
diff --git a/src/Entity/Group.php b/src/Entity/Group.php
index d6f37b8b3..59207cea1 100644
--- a/src/Entity/Group.php
+++ b/src/Entity/Group.php
@@ -200,7 +200,7 @@ public function findMargin(float $amount): ?GroupMargin
*
* @param float $amount the amount to get percent for
*
- * @return float the percent of the group margin, if found; 0 otherwise
+ * @return float the percentage of the group margin, if found; 0 otherwise
*
* @see Group::findMargin()
*/
diff --git a/src/Entity/User.php b/src/Entity/User.php
index 67738666c..ef2c0346e 100644
--- a/src/Entity/User.php
+++ b/src/Entity/User.php
@@ -412,7 +412,7 @@ public function setEnabled(bool $enabled): self
/**
* Sets image file.
*
- * If manually uploading a file (i.e., not using Symfony Form) ensure an instance
+ * If manually uploading a file (i.e., not using Symfony Form), ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
diff --git a/src/Enums/EntityName.php b/src/Enums/EntityName.php
index 241fde941..6c608ed9f 100644
--- a/src/Enums/EntityName.php
+++ b/src/Enums/EntityName.php
@@ -119,7 +119,7 @@ public static function constants(): array
}
/**
- * Gets the rights field name.
+ * Gets rights field name.
*/
public function getRightsField(): string
{
diff --git a/src/Enums/EntityPermission.php b/src/Enums/EntityPermission.php
index 2316c583c..3696636cc 100644
--- a/src/Enums/EntityPermission.php
+++ b/src/Enums/EntityPermission.php
@@ -32,37 +32,37 @@ enum EntityPermission: int implements EnumConstantsInterface, EnumSortableInterf
use TranslatableEnumTrait;
/**
- * Allow to add an entity.
+ * Allows adding an entity.
*/
#[EnumCase('add')]
case ADD = 1 << 0;
/**
- * Allow to delete an entity.
+ * Allows deleting an entity.
*/
#[EnumCase('delete')]
case DELETE = 1 << 1;
/**
- * Allow to edit an entity.
+ * Allows editing an entity.
*/
#[EnumCase('edit')]
case EDIT = 1 << 2;
/**
- * Allow to export entities.
+ * Allows exporting entities.
*/
#[EnumCase('export')]
case EXPORT = 1 << 3;
/**
- * Allow to list entities.
+ * Allows listing entities.
*/
#[EnumCase('list')]
case LIST = 1 << 4;
/**
- * Allow to show an entity.
+ * Allows showing an entity.
*/
#[EnumCase('show')]
case SHOW = 1 << 5;
diff --git a/src/Enums/Environment.php b/src/Enums/Environment.php
index bf2679a84..3ef1e6b61 100644
--- a/src/Enums/Environment.php
+++ b/src/Enums/Environment.php
@@ -50,7 +50,7 @@ public function isDevelopment(): bool
}
/**
- * Returns if this is enumeration the production environment.
+ * Returns if this enumeration is the production environment.
*
* @return bool true if production environment
*/
diff --git a/src/Enums/FlashType.php b/src/Enums/FlashType.php
index b4366f605..277d2661a 100644
--- a/src/Enums/FlashType.php
+++ b/src/Enums/FlashType.php
@@ -46,7 +46,7 @@ enum FlashType: string implements TranslatableEnumInterface
case SUCCESS = 'success';
/**
- * Warning flash bag.
+ * Warning flash-bag.
*/
#[EnumCase(extras: ['icon' => 'fas fa-lg fa-exclamation-circle'])]
case WARNING = 'warning';
diff --git a/src/Enums/MessagePosition.php b/src/Enums/MessagePosition.php
index da941ea94..32011d5da 100644
--- a/src/Enums/MessagePosition.php
+++ b/src/Enums/MessagePosition.php
@@ -21,7 +21,7 @@
use Elao\Enum\Bridge\Symfony\Translation\TranslatableEnumTrait;
/**
- * The message position for flash bag.
+ * The message position for flash-bag.
*
* @implements EnumDefaultInterfacetrue if a header row is drawing; false otherwise
+ */
+ public function isHeaders(): bool
+ {
+ return $this->isHeaders;
+ }
+
/**
* Returns if the header row is printed when a new page is added.
*/
@@ -710,8 +720,7 @@ protected function drawRow(
$parent->setX($x);
break;
case PdfTextAlignment::RIGHT:
- /** @psalm-var float $w */
- $w = \array_sum($widths);
+ $w = (float) \array_sum($widths);
$x = $parent->getPageWidth() - $parent->getRightMargin() - $w;
$parent->setX($x);
break;
@@ -809,19 +818,19 @@ private function adjustCellWidths(array $cells, array $fixeds, array &$widths):
return;
}
- // get fixed and resizable widths
+ // compute widths and check values
[$fixedWidth, $resizableWidth] = $this->computeCellWidths($fixeds, $widths);
+ $remainingWidth = $parent->getPrintableWidth() - $fixedWidth;
+ if ($this->isFloatZero($resizableWidth) || $this->isFloatZero($remainingWidth)
+ || $resizableWidth === $remainingWidth) {
+ return;
+ }
// update resizable widths
- $remainingWidth = $parent->getPrintableWidth() - $fixedWidth;
- if (!$this->isFloatZero($resizableWidth)
- && !$this->isFloatZero($remainingWidth)
- && $resizableWidth !== $remainingWidth) {
- $factor = $remainingWidth / $resizableWidth;
- for ($i = 0; $i < $count; ++$i) {
- if (!$fixeds[$i]) {
- $widths[$i] *= $factor;
- }
+ $factor = $remainingWidth / $resizableWidth;
+ for ($i = 0; $i < $count; ++$i) {
+ if (!$fixeds[$i]) {
+ $widths[$i] *= $factor;
}
}
}
@@ -848,6 +857,8 @@ private function checkRowStarted(): void
* 2: PdfTextAlignment[],
* 3: float[],
* 4: bool[]}
+ *
+ * @psalm-suppress PossiblyNullReference
*/
private function computeCells(array $cells, array $columns): array
{
diff --git a/src/Pdf/Traits/PdfBarChartTrait.php b/src/Pdf/Traits/PdfBarChartTrait.php
index 7a70eb0b6..4646cfae9 100644
--- a/src/Pdf/Traits/PdfBarChartTrait.php
+++ b/src/Pdf/Traits/PdfBarChartTrait.php
@@ -88,7 +88,7 @@ public function renderBarChart(
$h ??= 200.0;
$endY = $y + $h;
- // check new page
+ // check the new page
if (!$this->isPrintable($h, $y)) {
$this->addPage();
$y = $this->getY();
diff --git a/src/Pdf/Traits/PdfBookmarkTrait.php b/src/Pdf/Traits/PdfBookmarkTrait.php
index 0d66817db..004145330 100644
--- a/src/Pdf/Traits/PdfBookmarkTrait.php
+++ b/src/Pdf/Traits/PdfBookmarkTrait.php
@@ -67,8 +67,8 @@ trait PdfBookmarkTrait
* @throws PdfException if the given level is invalid. A level is not valid if:
*
*
*
* @see PdfDocument::addPageIndex()
@@ -108,14 +108,14 @@ public function addBookmark(
/**
* Add an index page (as new page) containing all bookmarks.
*
- * Each line contain the text on the left, the page number on the right and are separate by the given separator
+ * Each line contains the text on the left, the page number on the right and are separate by the given separator
* characters.
*
* Remark: Do nothing if no bookmark is defined.
*
* @param ?string $title the index title or null to use the default title ('Index')
* @param ?PdfStyle $titleStyle the title style or null to use the default style (Font Arial 9 points Bold)
- * @param ?PdfStyle $contentStyle the content style or null to use the default style (Font Arial 9 points Regular)
+ * @param ?PdfStyle $contentStyle the content style or null to use the default style (Font Arial 9-point Regular)
* @param bool $addBookmark true to add the index page itself in the list of the bookmarks
* @param string $separator the separator character used between the text and the page
*
diff --git a/src/Pdf/Traits/PdfCellTranslatorTrait.php b/src/Pdf/Traits/PdfCellTranslatorTrait.php
index 2c5e28f5c..7c6ead2bf 100644
--- a/src/Pdf/Traits/PdfCellTranslatorTrait.php
+++ b/src/Pdf/Traits/PdfCellTranslatorTrait.php
@@ -19,7 +19,7 @@
use Symfony\Contracts\Translation\TranslatableInterface;
/**
- * Trait to allow adding a translatable cell.
+ * Trait to allow adding translatable cells.
*
* @psalm-require-extends \App\Pdf\PdfTable
*/
diff --git a/src/Pdf/Traits/PdfColumnTranslatorTrait.php b/src/Pdf/Traits/PdfColumnTranslatorTrait.php
new file mode 100644
index 000000000..a55af60a4
--- /dev/null
+++ b/src/Pdf/Traits/PdfColumnTranslatorTrait.php
@@ -0,0 +1,73 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace App\Pdf\Traits;
+
+use App\Pdf\PdfColumn;
+use App\Traits\TranslatorTrait;
+use Symfony\Contracts\Translation\TranslatableInterface;
+
+/**
+ * Trait to allow adding translatable columns.
+ */
+trait PdfColumnTranslatorTrait
+{
+ use TranslatorTrait;
+
+ /**
+ * Create a column with center alignment and a translated text.
+ *
+ * @param string|\Stringable|TranslatableInterface $id the identifier to translate or an empty string if none
+ * @param float $width the column width
+ * @param bool $fixed true if the column width is fixed. This property is used
+ * only if the parent's table uses all the document width.
+ */
+ protected function centerColumn(
+ string|\Stringable|TranslatableInterface $id,
+ float $width,
+ bool $fixed = false
+ ): PdfColumn {
+ return PdfColumn::center('' !== $id ? $this->trans($id) : $id, $width, $fixed);
+ }
+
+ /**
+ * Create a column with left alignment and a translated text.
+ *
+ * @param string|\Stringable|TranslatableInterface $id the identifier to translate or an empty string if none
+ * @param float $width the column width
+ * @param bool $fixed true if the column width is fixed. This property is used
+ * only if the parent's table uses all the document width.
+ */
+ protected function leftColumn(
+ string|\Stringable|TranslatableInterface $id,
+ float $width,
+ bool $fixed = false
+ ): PdfColumn {
+ return PdfColumn::left('' !== $id ? $this->trans($id) : $id, $width, $fixed);
+ }
+
+ /**
+ * Create a column with right alignment and a translated text.
+ *
+ * @param string|\Stringable|TranslatableInterface $id the identifier to translate or an empty string if none
+ * @param float $width the column width
+ * @param bool $fixed true if the column width is fixed. This property is used
+ * only if the parent's table uses all the document width.
+ */
+ protected function rightColumn(
+ string|\Stringable|TranslatableInterface $id,
+ float $width,
+ bool $fixed = false
+ ): PdfColumn {
+ return PdfColumn::right('' !== $id ? $this->trans($id) : $id, $width, $fixed);
+ }
+}
diff --git a/src/Pdf/Traits/PdfDashLineTrait.php b/src/Pdf/Traits/PdfDashLineTrait.php
index a08f5855c..6be4c48e2 100644
--- a/src/Pdf/Traits/PdfDashLineTrait.php
+++ b/src/Pdf/Traits/PdfDashLineTrait.php
@@ -91,7 +91,7 @@ public function dashedRectangle(PdfRectangle $rectangle, int $dashes = 15, PdfLi
/**
* Set the dash pattern to draw dashed lines or rectangles.
*
- * Call the function without parameter to restore normal drawing.
+ * Call the function without the parameter to restore normal drawing.
*
* @param float|null $black the length of dashes
* @param float|null $white the length of gaps
diff --git a/src/Pdf/Traits/PdfMemoryImageTrait.php b/src/Pdf/Traits/PdfMemoryImageTrait.php
index fd2fbd3fc..696216875 100644
--- a/src/Pdf/Traits/PdfMemoryImageTrait.php
+++ b/src/Pdf/Traits/PdfMemoryImageTrait.php
@@ -25,7 +25,7 @@ trait PdfMemoryImageTrait
/**
* Output a GD image.
*
- * This function convert first the given image to the portable network graphics format ('png') before output.
+ * This function converts first the given image to the portable network graphics format ('png') before output.
*
* @param \GdImage $image the GD image to output
* @param ?float $x the abscissa of the upper-left corner. If null, the current abscissa
@@ -52,7 +52,7 @@ trait PdfMemoryImageTrait
*
* @param string|int|null $link the URL or an identifier returned by addLink()
*
- * @throws PdfException if the image can not be converted
+ * @throws PdfException if the image cannot be converted
*/
public function imageGD(
\GdImage $image,
@@ -72,7 +72,7 @@ public function imageGD(
}
/**
- * Output an image data.
+ * Output image data.
*
* @param string $data the image data to output
* @param ?float $x the abscissa of the upper-left corner. If null, the current abscissa
diff --git a/src/Pdf/Traits/PdfPieChartTrait.php b/src/Pdf/Traits/PdfPieChartTrait.php
index f48045c98..3c6007ef8 100644
--- a/src/Pdf/Traits/PdfPieChartTrait.php
+++ b/src/Pdf/Traits/PdfPieChartTrait.php
@@ -61,7 +61,7 @@ public function renderPieChart(
return;
}
- // check new page
+ // check the new page
if (!$this->isPrintable($radius, $centerY + $radius)) {
$this->addPage();
$centerY = $this->getY() + $radius;
diff --git a/src/Pdf/Traits/PdfSectorTrait.php b/src/Pdf/Traits/PdfSectorTrait.php
index 5dac04124..106bb2ce0 100644
--- a/src/Pdf/Traits/PdfSectorTrait.php
+++ b/src/Pdf/Traits/PdfSectorTrait.php
@@ -62,7 +62,7 @@ public function sector(
// put center
$this->outf('%.2F %.2F m', $centerX * $scaleFactor, ($height - $centerY) * $scaleFactor);
- // put first point
+ // put the first point
$x = ($centerX + $radius * \cos($startAngle)) * $scaleFactor;
$y = ($height - ($centerY - $radius * \sin($startAngle))) * $scaleFactor;
$this->outf('%.2F %.2F l', $x, $y);
diff --git a/src/Pivot/Field/PivotField.php b/src/Pivot/Field/PivotField.php
index 2bbc8f956..bf345b571 100644
--- a/src/Pivot/Field/PivotField.php
+++ b/src/Pivot/Field/PivotField.php
@@ -42,7 +42,8 @@ public function __construct(protected string $name, protected ?string $title = n
/**
* Gets the display value.
- * The default implementation returns the value as is. Subclass can override, for example to map the value.
+ *
+ * The default implementation returns the value as is. Subclass can override, for example, to map the value.
*
* @param mixed $value the field value
*
@@ -56,7 +57,7 @@ public function getDisplayValue(mixed $value): mixed
/**
* Gets the value method.
*
- * @return int one of the METHOD_XX constants
+ * @return int one of the METHOD_XX constants
*/
public function getMethod(): int
{
@@ -110,7 +111,7 @@ public function jsonSerialize(): array
/**
* Sets the value method.
*
- * @param int $method one of the METHOD_XX constants
+ * @param int $method one of the METHOD_XX constants
*/
public function setMethod(int $method): self
{
diff --git a/src/Pivot/Field/PivotFieldFactory.php b/src/Pivot/Field/PivotFieldFactory.php
index 40ac8d481..18822393a 100644
--- a/src/Pivot/Field/PivotFieldFactory.php
+++ b/src/Pivot/Field/PivotFieldFactory.php
@@ -22,7 +22,7 @@ class PivotFieldFactory
*
* @param string $name the field name
* @param ?string $title the field title
- * @param int $method the field method (one of the PivotField::METHOD_XX)
+ * @param int $method the field method (one of the PivotField::METHOD_XX)
*/
public static function default(string $name, ?string $title = null, int $method = PivotField::METHOD_STRING): PivotField
{
@@ -30,7 +30,7 @@ public static function default(string $name, ?string $title = null, int $method
}
/**
- * Creates a new instance with the METHOD_FLOAT.
+ * Creates a new instance with the METHOD_FLOAT.
*
* @param string $name the field name
* @param ?string $title the field title
@@ -41,7 +41,7 @@ public static function float(string $name, ?string $title = null): PivotField
}
/**
- * Creates a new instance with the METHOD_INTEGER.
+ * Creates a new instance with the METHOD_INTEGER.
*
* @param string $name the field name
* @param ?string $title the field title
@@ -75,7 +75,7 @@ public static function quarter(string $name, ?string $title = null): PivotQuarte
}
/**
- * Creates a new date instance for semester.
+ * Creates a new date instance for the semester.
*
* @param string $name the field name
* @param ?string $title the field title
@@ -101,7 +101,7 @@ public static function week(string $name, ?string $title = null): PivotDateField
*
* @param string $name the field name
* @param ?string $title the field title
- * @param bool $short true to display the short day name, false to display the full day name
+ * @param bool $short true to display the short day name, false to display the full-day name
*/
public static function weekday(string $name, ?string $title = null, bool $short = false): PivotWeekdayField
{
@@ -109,7 +109,7 @@ public static function weekday(string $name, ?string $title = null, bool $short
}
/**
- * Creates a new date instance for year.
+ * Creates a new date instance for the year.
*
* @param string $name the field name
* @param ?string $title the field title
diff --git a/src/Pivot/Field/PivotMonthField.php b/src/Pivot/Field/PivotMonthField.php
index 77f4f8675..1add61bab 100644
--- a/src/Pivot/Field/PivotMonthField.php
+++ b/src/Pivot/Field/PivotMonthField.php
@@ -15,7 +15,7 @@
use App\Utils\DateUtils;
/**
- * Pivot field that map month values (1...12) to month names (january, february, etc...).
+ * The pivot field that maps month values (1...12) to month names (january, february, etc...).
*/
class PivotMonthField extends PivotDateField
{
diff --git a/src/Pivot/Field/PivotQuarterField.php b/src/Pivot/Field/PivotQuarterField.php
index 1dd034ae1..df6adc75a 100644
--- a/src/Pivot/Field/PivotQuarterField.php
+++ b/src/Pivot/Field/PivotQuarterField.php
@@ -13,7 +13,7 @@
namespace App\Pivot\Field;
/**
- * Pivot field that extract quarter (1 or 4).
+ * The pivot field that extracts quarter (1 or 4).
*/
class PivotQuarterField extends PivotDateField
{
@@ -45,7 +45,7 @@ public function getFormatter(): ?callable
/**
* Sets callback used to format a quarter.
*
- * The function receive the quarter (1 to 4) as parameter and must return a string.
+ * The function receives the quarter (1 to 4) as a parameter and must return a string.
*
* @param ?callable $formatter the optional callback
*
diff --git a/src/Pivot/Field/PivotSemesterField.php b/src/Pivot/Field/PivotSemesterField.php
index 7c48e536a..69b0cc661 100644
--- a/src/Pivot/Field/PivotSemesterField.php
+++ b/src/Pivot/Field/PivotSemesterField.php
@@ -13,7 +13,7 @@
namespace App\Pivot\Field;
/**
- * Pivot field that extract semester (1 or 2).
+ * The Pivot field that extracts semester (1 or 2).p.
*/
class PivotSemesterField extends PivotDateField
{
@@ -45,7 +45,7 @@ public function getFormatter(): ?callable
/**
* Sets callback used to format a semestre.
*
- * The function receive the semestre (1 or 2 ) as parameter and must return a string.
+ * The function receives the semestre (1 or 2) as a parameter and must return a string.
*
* @param ?callable $formatter the optional callback
*
diff --git a/src/Pivot/PivotNode.php b/src/Pivot/PivotNode.php
index 604314042..b4e711b85 100644
--- a/src/Pivot/PivotNode.php
+++ b/src/Pivot/PivotNode.php
@@ -502,7 +502,7 @@ public function setParent(?self $parent): self
}
/**
- * Sets the sort mode and sort values if different from current sort mode.
+ * Sets the sort mode and sort values if different from the current sort mode.
*
* @psalm-api
*/
diff --git a/src/Pivot/PivotTable.php b/src/Pivot/PivotTable.php
index d14d9610a..b0992603d 100644
--- a/src/Pivot/PivotTable.php
+++ b/src/Pivot/PivotTable.php
@@ -301,7 +301,7 @@ public function setDataField(PivotField $dataField): self
}
/**
- * Sets the key field.
+ * Sets the key field.
*/
public function setKeyField(PivotField $keyField): self
{
diff --git a/src/Report/AbstractArrayReport.php b/src/Report/AbstractArrayReport.php
index 848b0f16c..b562f038e 100644
--- a/src/Report/AbstractArrayReport.php
+++ b/src/Report/AbstractArrayReport.php
@@ -39,11 +39,7 @@ public function __construct(
public function render(): bool
{
- if ([] === $this->entities) {
- return false;
- }
-
- return $this->doRender($this->entities);
+ return [] !== $this->entities && $this->doRender($this->entities);
}
/**
diff --git a/src/Report/AbstractCalculationItemsReport.php b/src/Report/AbstractCalculationItemsReport.php
index c89994969..6af075764 100644
--- a/src/Report/AbstractCalculationItemsReport.php
+++ b/src/Report/AbstractCalculationItemsReport.php
@@ -14,7 +14,6 @@
use App\Controller\AbstractController;
use App\Pdf\Colors\PdfTextColor;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfStyle;
use App\Pdf\PdfTable;
use App\Utils\FormatUtils;
@@ -104,12 +103,12 @@ private function createTable(): PdfTable
{
return PdfTable::instance($this)
->addColumns(
- PdfColumn::center($this->trans('calculation.fields.id'), 17, true),
- PdfColumn::center($this->trans('calculation.fields.date'), 20, true),
- PdfColumn::left($this->trans('calculation.fields.state'), 20, true),
- PdfColumn::left($this->trans('calculation.fields.customer'), 60),
- PdfColumn::left($this->trans('calculation.fields.description'), 60),
- PdfColumn::left($this->trans('calculation.fields.items'), 70),
+ $this->centerColumn('calculation.fields.id', 17, true),
+ $this->centerColumn('calculation.fields.date', 20, true),
+ $this->leftColumn('calculation.fields.state', 20, true),
+ $this->leftColumn('calculation.fields.customer', 60),
+ $this->leftColumn('calculation.fields.description', 60),
+ $this->leftColumn('calculation.fields.items', 70),
)->outputHeaders();
}
}
diff --git a/src/Report/AbstractReport.php b/src/Report/AbstractReport.php
index 49189e30d..8f2d3165a 100644
--- a/src/Report/AbstractReport.php
+++ b/src/Report/AbstractReport.php
@@ -16,7 +16,7 @@
use App\Pdf\PdfDocument;
use App\Pdf\PdfStyle;
use App\Pdf\PdfTable;
-use App\Traits\TranslatorTrait;
+use App\Pdf\Traits\PdfColumnTranslatorTrait;
use fpdf\PdfOrientation;
use fpdf\PdfPageSize;
use fpdf\PdfTextAlignment;
@@ -28,7 +28,7 @@
*/
abstract class AbstractReport extends PdfDocument
{
- use TranslatorTrait;
+ use PdfColumnTranslatorTrait;
private readonly TranslatorInterface $translator;
@@ -54,7 +54,7 @@ public function __construct(
/**
* {@inheritdoc}
*
- * Override the default behavior by adding a translated title if null and the page index to bookmarks.
+ * Override the default behavior by adding a translated title if null and the page index to the bookmarks.
*/
public function addPageIndex(
?string $title = null,
@@ -77,33 +77,36 @@ public function getTranslator(): TranslatorInterface
/**
* Render this document.
*
- * @return bool true if rendered successfully
+ * @return bool true if rendered successfully
*/
abstract public function render(): bool;
/**
* Renders a single line with the given number of elements.
*
- * @return bool true if the given number of elements is greater than 0
+ * @return bool true if the given number of elements is greater than 0
*/
public function renderCount(PdfTable $table, \Countable|array|int $count, string $message = 'common.count'): bool
{
$this->resetStyle();
+ if (!\is_int($count)) {
+ $count = \count($count);
+ }
$text = $this->translateCount($count, $message);
$table->singleLine($text, PdfStyle::getHeaderStyle(), PdfTextAlignment::LEFT);
- return $this->toInt($count) > 0;
+ return $count > 0;
}
/**
* Sets the title to be translated.
*
- * @param string $id the title id (may also be an object that can be cast to string)
+ * @param string $id the title identifier (may also be an object that can be cast to string)
* @param bool $isUTF8 indicates if the title is encoded in ISO-8859-1 (false) or UTF-8 (true)
*/
- public function setTitleTrans(string $id, array $parameters = [], bool $isUTF8 = false, ?string $domain = null): static
+ public function setTitleTrans(string $id, array $parameters = [], bool $isUTF8 = false): static
{
- $title = $this->trans($id, $parameters, $domain);
+ $title = $this->trans($id, $parameters);
$this->setTitle($title, $isUTF8);
return $this;
@@ -114,11 +117,10 @@ public function setTitleTrans(string $id, array $parameters = [], bool $isUTF8 =
*/
protected function translateCount(\Countable|array|int $count, string $message = 'common.count'): string
{
- return $this->trans($message, ['%count%' => $this->toInt($count)]);
- }
+ if (!\is_int($count)) {
+ $count = \count($count);
+ }
- private function toInt(\Countable|array|int $value): int
- {
- return \is_int($value) ? $value : \count($value);
+ return $this->trans($message, ['%count%' => $count]);
}
}
diff --git a/src/Report/CalculationByMonthReport.php b/src/Report/CalculationByMonthReport.php
index 46281c62c..8a22984e1 100644
--- a/src/Report/CalculationByMonthReport.php
+++ b/src/Report/CalculationByMonthReport.php
@@ -25,7 +25,6 @@
use App\Pdf\Interfaces\PdfDrawCellTextInterface;
use App\Pdf\Interfaces\PdfDrawHeadersInterface;
use App\Pdf\PdfCell;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfStyle;
use App\Pdf\Traits\PdfBarChartTrait;
use App\Pdf\Traits\PdfChartLegendTrait;
@@ -152,12 +151,12 @@ private function createTable(): ReportTable
{
return ReportTable::fromReport($this)
->addColumns(
- PdfColumn::left($this->trans('chart.month.fields.month'), 20),
- PdfColumn::right($this->trans('calculation.list.title'), 22, true),
- PdfColumn::right($this->trans('calculationgroup.fields.amount'), 25, true),
- PdfColumn::right($this->trans('calculation.fields.margin'), 20, true),
- PdfColumn::right('', 18, true),
- PdfColumn::right($this->trans('calculation.fields.total'), 25, true),
+ $this->leftColumn('chart.month.fields.month', 20),
+ $this->rightColumn('calculation.list.title', 22, true),
+ $this->rightColumn('calculationgroup.fields.amount', 25, true),
+ $this->rightColumn('calculation.fields.margin', 20, true),
+ $this->rightColumn('', 18, true),
+ $this->rightColumn('calculation.fields.total', 25, true),
)
->setHeadersListener($this)
->setTextListener($this)
diff --git a/src/Report/CalculationByStateReport.php b/src/Report/CalculationByStateReport.php
index b63c5e14d..1226bc614 100644
--- a/src/Report/CalculationByStateReport.php
+++ b/src/Report/CalculationByStateReport.php
@@ -21,7 +21,6 @@
use App\Pdf\Interfaces\PdfDrawCellTextInterface;
use App\Pdf\Interfaces\PdfDrawHeadersInterface;
use App\Pdf\PdfCell;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfStyle;
use App\Pdf\Traits\PdfChartLegendTrait;
use App\Pdf\Traits\PdfPieChartTrait;
@@ -143,14 +142,14 @@ private function createTable(): ReportTable
->setHeadersListener($this)
->setTextListener($this)
->addColumns(
- PdfColumn::left($this->trans('calculation.fields.state'), 20),
- PdfColumn::right($this->trans('calculation.list.title'), 18, true),
- PdfColumn::right('', 18, true),
- PdfColumn::right($this->trans('calculationgroup.fields.amount'), 24, true),
- PdfColumn::right($this->trans('calculation.fields.margin'), 24, true),
- PdfColumn::right('', 14, true),
- PdfColumn::right($this->trans('calculation.fields.total'), 24, true),
- PdfColumn::right('', 18, true)
+ $this->leftColumn('calculation.fields.state', 20),
+ $this->rightColumn('calculation.list.title', 18, true),
+ $this->rightColumn('', 18, true),
+ $this->rightColumn('calculationgroup.fields.amount', 24, true),
+ $this->rightColumn('calculation.fields.margin', 24, true),
+ $this->rightColumn('', 14, true),
+ $this->rightColumn('calculation.fields.total', 24, true),
+ $this->rightColumn('', 18, true)
)->outputHeaders();
}
@@ -191,14 +190,13 @@ private function getPercentCell(
bool $bold = false,
int $roundingMode = \NumberFormatter::ROUND_HALFDOWN
): PdfCell {
+ $text = FormatUtils::formatPercent($value, true, $decimals, $roundingMode);
$style = $bold ? PdfStyle::getHeaderStyle() : PdfStyle::getCellStyle();
- $cell = new PdfCell(FormatUtils::formatPercent($value, true, $decimals, $roundingMode));
if ($useStyle && $this->isMinMargin($value)) {
$style->setTextColor(PdfTextColor::red());
}
- $cell->setStyle($style);
- return $cell;
+ return new PdfCell($text, style: $style);
}
private function getURL(int $id): string
diff --git a/src/Report/CalculationReport.php b/src/Report/CalculationReport.php
index d3d99a729..b2a303f93 100644
--- a/src/Report/CalculationReport.php
+++ b/src/Report/CalculationReport.php
@@ -14,7 +14,6 @@
use App\Controller\AbstractController;
use App\Entity\Calculation;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfStyle;
use App\Pdf\PdfTable;
use App\Pdf\Traits\PdfMemoryImageTrait;
@@ -145,8 +144,8 @@ private function renderCalculation(): void
$calculation = $this->calculation;
PdfTable::instance($this)
->addColumns(
- PdfColumn::left(null, 100),
- PdfColumn::right(null, 40, true)
+ $this->leftColumn('', 100),
+ $this->rightColumn('', 40, true)
)
->startHeaderRow()
->add($calculation->getCustomer(), style: $leftStyle)
diff --git a/src/Report/CalculationStatesReport.php b/src/Report/CalculationStatesReport.php
index 42eb05e66..128c2d825 100644
--- a/src/Report/CalculationStatesReport.php
+++ b/src/Report/CalculationStatesReport.php
@@ -16,7 +16,6 @@
use App\Pdf\Colors\PdfFillColor;
use App\Pdf\Events\PdfCellBackgroundEvent;
use App\Pdf\Interfaces\PdfDrawCellBackgroundInterface;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfStyle;
use App\Pdf\PdfTable;
use fpdf\PdfRectangleStyle;
@@ -52,6 +51,7 @@ protected function doRender(array $entities): bool
$this->addPage();
$table = $this->createTable();
+ $total = 0;
foreach ($entities as $entity) {
$this->currentState = $entity;
$table->startRow()
@@ -62,9 +62,15 @@ protected function doRender(array $entities): bool
->addCellInt($entity->countCalculations())
->endRow();
$this->currentState = null;
+ $total += $entity->countCalculations();
}
- return $this->renderCount($table, $entities, 'counters.states');
+ $table->startHeaderRow()
+ ->add($this->translateCount($entities, 'counters.states'), 4)
+ ->addCellInt($total)
+ ->endRow();
+
+ return true;
}
private function createTable(): PdfTable
@@ -72,11 +78,11 @@ private function createTable(): PdfTable
return PdfTable::instance($this)
->setBackgroundListener($this)
->addColumns(
- PdfColumn::left($this->trans('calculationstate.fields.code'), 20),
- PdfColumn::left($this->trans('calculationstate.fields.description'), 80),
- PdfColumn::center($this->trans('calculationstate.fields.editable'), 20, true),
- PdfColumn::center($this->trans('calculationstate.fields.color'), 15, true),
- PdfColumn::right($this->trans('calculationstate.fields.calculations'), 22, true)
+ $this->leftColumn('calculationstate.fields.code', 20),
+ $this->leftColumn('calculationstate.fields.description', 80),
+ $this->centerColumn('calculationstate.fields.editable', 20, true),
+ $this->centerColumn('calculationstate.fields.color', 15, true),
+ $this->rightColumn('calculationstate.fields.calculations', 22, true)
)->outputHeaders();
}
diff --git a/src/Report/CalculationsBelowReport.php b/src/Report/CalculationsBelowReport.php
index 5daa1ca50..beaa12d9a 100644
--- a/src/Report/CalculationsBelowReport.php
+++ b/src/Report/CalculationsBelowReport.php
@@ -15,7 +15,6 @@
use App\Controller\AbstractController;
use App\Entity\Calculation;
use App\Pdf\Colors\PdfTextColor;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfStyle;
use App\Pdf\PdfTable;
use App\Traits\MathTrait;
@@ -64,14 +63,14 @@ private function createTable(): PdfTable
{
return PdfTable::instance($this)
->addColumns(
- PdfColumn::center($this->trans('calculation.fields.id'), 17, true),
- PdfColumn::center($this->trans('calculation.fields.date'), 20, true),
- PdfColumn::left($this->trans('calculation.fields.state'), 20, true),
- PdfColumn::left($this->trans('calculation.fields.customer'), 35),
- PdfColumn::left($this->trans('calculation.fields.description'), 65),
- PdfColumn::right($this->trans('report.calculation.amount'), 25, true),
- PdfColumn::right($this->trans('report.calculation.margin_percent'), 20, true),
- PdfColumn::right($this->trans('calculation.fields.total'), 25, true),
+ $this->centerColumn('calculation.fields.id', 17, true),
+ $this->centerColumn('calculation.fields.date', 20, true),
+ $this->leftColumn('calculation.fields.state', 20, true),
+ $this->leftColumn('calculation.fields.customer', 35),
+ $this->leftColumn('calculation.fields.description', 65),
+ $this->rightColumn('report.calculation.amount', 25, true),
+ $this->rightColumn('report.calculation.margin_percent', 20, true),
+ $this->rightColumn('calculation.fields.total', 25, true),
)->outputHeaders();
}
diff --git a/src/Report/CalculationsReport.php b/src/Report/CalculationsReport.php
index 29d2ec4ea..f91ad90fe 100644
--- a/src/Report/CalculationsReport.php
+++ b/src/Report/CalculationsReport.php
@@ -15,7 +15,6 @@
use App\Controller\AbstractController;
use App\Entity\Calculation;
use App\Pdf\Colors\PdfTextColor;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfGroupTable;
use App\Pdf\PdfStyle;
use App\Traits\MathTrait;
@@ -76,13 +75,13 @@ private function createTable(): PdfGroupTable
{
return PdfGroupTable::instance($this)
->addColumns(
- PdfColumn::center($this->trans('calculation.fields.id'), 17, true),
- PdfColumn::center($this->trans('calculation.fields.date'), 20, true),
- PdfColumn::left($this->trans('calculation.fields.customer'), 35),
- PdfColumn::left($this->trans('calculation.fields.description'), 65),
- PdfColumn::right($this->trans('report.calculation.amount'), 25, true),
- PdfColumn::right($this->trans('report.calculation.margin_percent'), 20, true),
- PdfColumn::right($this->trans('calculation.fields.total'), 25, true),
+ $this->centerColumn('calculation.fields.id', 17, true),
+ $this->centerColumn('calculation.fields.date', 20, true),
+ $this->leftColumn('calculation.fields.customer', 35),
+ $this->leftColumn('calculation.fields.description', 65),
+ $this->rightColumn('report.calculation.amount', 25, true),
+ $this->rightColumn('report.calculation.margin_percent', 20, true),
+ $this->rightColumn('calculation.fields.total', 25, true),
)->outputHeaders();
}
diff --git a/src/Report/CategoriesReport.php b/src/Report/CategoriesReport.php
index 0edd54063..bada19b26 100644
--- a/src/Report/CategoriesReport.php
+++ b/src/Report/CategoriesReport.php
@@ -13,7 +13,6 @@
namespace App\Report;
use App\Entity\Category;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfGroupTable;
use App\Pdf\PdfStyle;
use App\Traits\GroupByTrait;
@@ -74,10 +73,10 @@ private function createTable(): PdfGroupTable
{
return PdfGroupTable::instance($this)
->addColumns(
- PdfColumn::left($this->trans('category.fields.code'), 45, true),
- PdfColumn::left($this->trans('category.fields.description'), 50),
- PdfColumn::right($this->trans('category.fields.products'), 26, true),
- PdfColumn::right($this->trans('category.fields.tasks'), 26, true)
+ $this->leftColumn('category.fields.code', 45, true),
+ $this->leftColumn('category.fields.description', 50),
+ $this->rightColumn('category.fields.products', 26, true),
+ $this->rightColumn('category.fields.tasks', 26, true)
)->outputHeaders();
}
diff --git a/src/Report/CommandsReport.php b/src/Report/CommandsReport.php
index 2e7ab86eb..48eff6aaf 100644
--- a/src/Report/CommandsReport.php
+++ b/src/Report/CommandsReport.php
@@ -249,7 +249,10 @@ private function renderStyledHelp(string $help): void
$result = \preg_match_all(self::CLASS_PATTERN, $help, $matches, \PREG_SET_ORDER | \PREG_OFFSET_CAPTURE);
if (false === $result || 0 === $result) {
$this->outputHelp($help);
- goto restore;
+ $this->leftMargin = $oldMargin;
+ $this->lineBreak();
+
+ return;
}
$offset = 0;
@@ -275,7 +278,6 @@ private function renderStyledHelp(string $help): void
}
// restore
- restore:
$this->leftMargin = $oldMargin;
$this->lineBreak();
}
diff --git a/src/Report/CustomersReport.php b/src/Report/CustomersReport.php
index 9666cd27b..ac03ea1fb 100644
--- a/src/Report/CustomersReport.php
+++ b/src/Report/CustomersReport.php
@@ -14,7 +14,6 @@
use App\Controller\AbstractController;
use App\Entity\Customer;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfGroupTable;
use App\Pdf\PdfStyle;
use App\Utils\StringUtils;
@@ -47,9 +46,9 @@ protected function doRender(array $entities): bool
$table = PdfGroupTable::instance($this)
->setGroupStyle(PdfStyle::getHeaderStyle())
->addColumns(
- PdfColumn::left($this->trans('customer.fields.nameAndCompany'), 50),
- PdfColumn::left($this->trans('customer.fields.address'), 25),
- PdfColumn::left($this->trans('customer.fields.zipCity'), 25)
+ $this->leftColumn('customer.fields.nameAndCompany', 50),
+ $this->leftColumn('customer.fields.address', 25),
+ $this->leftColumn('customer.fields.zipCity', 25)
)->outputHeaders();
if ($this->grouped) {
diff --git a/src/Report/GlobalMarginsReport.php b/src/Report/GlobalMarginsReport.php
index 653fb836f..ce4ea549e 100644
--- a/src/Report/GlobalMarginsReport.php
+++ b/src/Report/GlobalMarginsReport.php
@@ -12,7 +12,6 @@
namespace App\Report;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfTable;
/**
@@ -29,10 +28,10 @@ protected function doRender(array $entities): bool
$table = PdfTable::instance($this)
->addColumns(
- PdfColumn::right($this->trans('globalmargin.fields.minimum'), 50),
- PdfColumn::right($this->trans('globalmargin.fields.maximum'), 50),
- PdfColumn::right($this->trans('globalmargin.fields.delta'), 50),
- PdfColumn::right($this->trans('globalmargin.fields.margin'), 50)
+ $this->rightColumn('globalmargin.fields.minimum', 50),
+ $this->rightColumn('globalmargin.fields.maximum', 50),
+ $this->rightColumn('globalmargin.fields.delta', 50),
+ $this->rightColumn('globalmargin.fields.margin', 50)
)->outputHeaders();
foreach ($entities as $entity) {
diff --git a/src/Report/GroupsReport.php b/src/Report/GroupsReport.php
index fe0c5764a..3aae1ac50 100644
--- a/src/Report/GroupsReport.php
+++ b/src/Report/GroupsReport.php
@@ -14,14 +14,12 @@
use App\Controller\AbstractController;
use App\Entity\Group;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfStyle;
use App\Pdf\PdfTable;
+use App\Report\Table\ReportTable;
use App\Utils\FormatUtils;
use fpdf\PdfBorder;
use fpdf\PdfOrientation;
-use fpdf\PdfPageSize;
-use fpdf\PdfUnit;
/**
* Report for the list of groups.
@@ -35,17 +33,14 @@ class GroupsReport extends AbstractArrayReport
*/
public function __construct(
AbstractController $controller,
- array $entities,
- PdfUnit $unit = PdfUnit::MILLIMETER,
- PdfPageSize $size = PdfPageSize::A4
+ array $entities
) {
- parent::__construct($controller, $entities, PdfOrientation::LANDSCAPE, $unit, $size);
+ parent::__construct($controller, $entities, PdfOrientation::LANDSCAPE);
+ $this->setTitleTrans('group.list.title');
}
protected function doRender(array $entities): bool
{
- $this->setTitleTrans('group.list.title', [], true);
-
$this->addPage();
$table = $this->createTable();
$last = \end($entities);
@@ -56,38 +51,60 @@ protected function doRender(array $entities): bool
$table->singleLine(null, $emptyStyle);
}
}
- $this->renderTotal($table, $entities);
+ $this->outputTotals($table, $entities);
return true;
}
- private function createTable(): PdfTable
+ private function createTable(): ReportTable
{
- return PdfTable::instance($this)
+ return ReportTable::fromReport($this)
->addColumns(
- PdfColumn::left($this->trans('group.fields.code'), 40, true),
- PdfColumn::left($this->trans('group.fields.description'), 50),
- PdfColumn::right($this->trans('group.fields.categories'), 26, true),
- PdfColumn::right($this->trans('category.fields.products'), 26, true),
- PdfColumn::right($this->trans('category.fields.tasks'), 26, true),
- PdfColumn::right($this->trans('globalmargin.fields.minimum'), 22, true),
- PdfColumn::right($this->trans('globalmargin.fields.maximum'), 22, true),
- PdfColumn::right($this->trans('globalmargin.fields.delta'), 22, true),
- PdfColumn::right($this->trans('globalmargin.fields.margin'), 22, true)
+ $this->leftColumn('group.fields.code', 45, true),
+ $this->leftColumn('group.fields.description', 50),
+ $this->rightColumn('group.fields.categories', 26, true),
+ $this->rightColumn('category.fields.products', 26, true),
+ $this->rightColumn('category.fields.tasks', 26, true),
+ $this->rightColumn('globalmargin.fields.minimum', 22, true),
+ $this->rightColumn('globalmargin.fields.maximum', 22, true),
+ $this->rightColumn('globalmargin.fields.margin', 22, true)
)->outputHeaders();
}
- private function formatCount(string $id, array|int $value): string
+ private function formatCount(string $id, int $value): string
{
- return $this->trans($id, ['count' => \is_array($value) ? \count($value) : $value]);
+ return $this->trans($id, ['count' => $value]);
}
private function formatInt(int $value): string
{
- return 0 === $value ? '' : FormatUtils::formatInt($value);
+ return 0 !== $value ? FormatUtils::formatInt($value) : '';
+ }
+
+ /**
+ * @param Group[] $entities
+ *
+ * @return int[]
+ */
+ private function getTotals(array $entities): array
+ {
+ return \array_reduce(
+ $entities,
+ /** @psalm-param int[] $carry */
+ function (array $carry, Group $group): array {
+ ++$carry[0];
+ $carry[1] += $group->countCategories();
+ $carry[2] += $group->countProducts();
+ $carry[3] += $group->countTasks();
+ $carry[4] += $group->countMargins();
+
+ return $carry;
+ },
+ [0, 0, 0, 0, 0]
+ );
}
- private function outputGroup(PdfTable $table, Group $group): void
+ private function outputGroup(ReportTable $table, Group $group): void
{
$emptyValue = \array_fill(0, 5, '');
$table->startRow()
@@ -106,46 +123,35 @@ private function outputGroup(PdfTable $table, Group $group): void
}
$table->addCellAmount($margin->getMinimum())
->addCellAmount($margin->getMaximum())
- ->addCellAmount($margin->getDelta())
->addCellPercent($margin->getMargin())
->endRow();
$skip = true;
}
} else {
- $empty = $this->trans('group.edit.empty_margins');
- $table->add($empty, 4)->endRow();
+ $table->addCellTrans('group.edit.empty_margins', 3)->endRow();
}
}
/**
* @param Group[] $entities
*/
- private function renderTotal(PdfTable $table, array $entities): void
+ private function outputTotals(PdfTable $table, array $entities): void
{
- $margins = 0;
- $categories = 0;
- $products = 0;
- $tasks = 0;
-
- foreach ($entities as $entity) {
- $margins += $entity->countMargins();
- $categories += $entity->countCategories();
- $products += $entity->countProducts();
- $tasks += $entity->countTasks();
- }
-
- $txtEntities = $this->formatCount('counters.groups', $entities);
- $txtCategories = $this->formatCount('counters.categories', $categories);
- $txtProducts = $this->formatCount('counters.products', $products);
- $txtTasks = $this->formatCount('counters.tasks', $tasks);
- $txtMargins = $this->formatCount('counters.margins', $margins);
+ $values = $this->getTotals($entities);
+ $texts = [
+ $this->formatCount('counters.groups', $values[0]),
+ $this->formatCount('counters.categories', $values[1]),
+ $this->formatCount('counters.products', $values[2]),
+ $this->formatCount('counters.tasks', $values[3]),
+ $this->formatCount('counters.margins', $values[4]),
+ ];
$table->startHeaderRow()
- ->add($txtEntities, 2)
- ->add($txtCategories)
- ->add($txtProducts)
- ->add($txtTasks)
- ->add($txtMargins, 4)
+ ->add($texts[0], 2)
+ ->add($texts[1])
+ ->add($texts[2])
+ ->add($texts[3])
+ ->add($texts[4], 3)
->endRow();
}
}
diff --git a/src/Report/HelpReport.php b/src/Report/HelpReport.php
index 8d5cb0ad5..5b66fd88c 100644
--- a/src/Report/HelpReport.php
+++ b/src/Report/HelpReport.php
@@ -14,7 +14,6 @@
use App\Controller\AbstractController;
use App\Pdf\Colors\PdfDrawColor;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfStyle;
use App\Pdf\PdfTable;
use App\Service\HelpService;
@@ -144,8 +143,8 @@ private function outputActions(array $actions, string $description): void
$this->outputText($description);
$table = PdfTable::instance($this)
->addColumns(
- PdfColumn::left($this->trans('help.fields.action'), 70, true),
- PdfColumn::left($this->trans('help.fields.description'), 50)
+ $this->leftColumn('help.fields.action', 70, true),
+ $this->leftColumn('help.fields.description', 50)
)->outputHeaders();
foreach ($actions as $action) {
@@ -170,8 +169,8 @@ private function outputColumns(array $item, array $fields): void
$table = PdfTable::instance($this)
->addColumns(
- PdfColumn::left($this->trans('help.fields.column'), 30, true),
- PdfColumn::left($this->trans('help.fields.description'), 50)
+ $this->leftColumn('help.fields.column', 30, true),
+ $this->leftColumn('help.fields.description', 50)
)->outputHeaders();
foreach ($fields as $field) {
$table->addRow(
@@ -302,8 +301,8 @@ private function outputDialogFields(array $item): void
$this->multiCell(text: $text);
$table = PdfTable::instance($this)
->addColumns(
- PdfColumn::left($this->trans('help.fields.column'), 30, true),
- PdfColumn::left($this->trans('help.fields.description'), 50),
+ $this->leftColumn('help.fields.column', 30, true),
+ $this->leftColumn('help.fields.description', 50),
)->outputHeaders();
foreach ($fields as $field) {
$table->addRow(
@@ -479,10 +478,10 @@ private function outputFields(array $item, array $fields): void
$table = PdfTable::instance($this)
->addColumns(
- PdfColumn::left($this->trans('help.fields.field'), 30, true),
- PdfColumn::left($this->trans('help.fields.description'), 50),
- PdfColumn::left($this->trans('help.fields.type'), 30, true),
- PdfColumn::center($this->trans('help.fields.required'), 18, true)
+ $this->leftColumn('help.fields.field', 30, true),
+ $this->leftColumn('help.fields.description', 50),
+ $this->leftColumn('help.fields.type', 30, true),
+ $this->centerColumn('help.fields.required', 18, true)
)->outputHeaders();
foreach ($fields as $field) {
@@ -546,8 +545,8 @@ private function outputMainMenus(array $menus): bool
$this->outputText('help.labels.edit_actions');
$table = PdfTable::instance($this)
->addColumns(
- PdfColumn::left($this->trans('help.fields.action'), 60, true),
- PdfColumn::left($this->trans('help.fields.description'), 50)
+ $this->leftColumn('help.fields.action', 60, true),
+ $this->leftColumn('help.fields.description', 50)
)->outputHeaders();
$this->outputMenus($table, $menus);
diff --git a/src/Report/LogsReport.php b/src/Report/LogsReport.php
index 692510964..f0b6199b4 100644
--- a/src/Report/LogsReport.php
+++ b/src/Report/LogsReport.php
@@ -48,7 +48,7 @@ class LogsReport extends AbstractReport implements PdfDrawCellBorderInterface
private const FULL_WIDTH = 0.5;
/**
- * The half borderline width.
+ * The half-borderline width.
*/
private const HALF_WIDTH = 0.25;
@@ -81,6 +81,7 @@ public function __construct(AbstractController $controller, private readonly Log
public function drawCellBorder(PdfCellBorderEvent $event): bool
{
+ // cards
if ($this->drawCards) {
$columns = $event->table->getColumns();
$text = $columns[$event->index]->getText();
@@ -88,7 +89,12 @@ public function drawCellBorder(PdfCellBorderEvent $event): bool
return $this->drawBorder($event, $text);
}
- return (0 === $event->index) && $this->drawBorder($event, $this->level);
+ // row
+ if (!$event->table->isHeaders() && 0 === $event->index) {
+ return $this->drawBorder($event, $this->level);
+ }
+
+ return false;
}
public function render(): bool
@@ -123,7 +129,7 @@ private function cellTitle(): void
private function drawBorder(PdfCellBorderEvent $event, ?string $level): bool
{
- if (null === $level || '' === $level) {
+ if (!StringUtils::isString($level)) {
return false;
}
@@ -237,11 +243,11 @@ private function outputLogs(array $logs): void
$this->cellTitle();
$table = PdfTable::instance($this)
->addColumns(
- PdfColumn::left($this->trans('log.fields.level'), 20, true),
- PdfColumn::left($this->trans('log.fields.channel'), 20, true),
- PdfColumn::left($this->trans('log.fields.createdAt'), 34, true),
- PdfColumn::left($this->trans('log.fields.message'), 150),
- PdfColumn::left($this->trans('log.fields.user'), 20, true)
+ $this->leftColumn('log.fields.createdAt', 34, true),
+ $this->leftColumn('log.fields.message', 150),
+ $this->leftColumn('log.fields.level', 20, true),
+ $this->leftColumn('log.fields.channel', 20, true),
+ $this->leftColumn('log.fields.user', 20, true)
)
->outputHeaders()
->setBorderListener($this);
@@ -254,10 +260,10 @@ private function outputLogs(array $logs): void
$this->addDateBookmark($date);
}
$table->addRow(
- $log->getLevel(true),
- $log->getChannel(true),
$log->getFormattedDate(),
$log->getMessage(),
+ $log->getLevel(true),
+ $log->getChannel(true),
$log->getUser()
);
}
diff --git a/src/Report/ProductsReport.php b/src/Report/ProductsReport.php
index e9aaf1695..fd725121b 100644
--- a/src/Report/ProductsReport.php
+++ b/src/Report/ProductsReport.php
@@ -13,7 +13,6 @@
namespace App\Report;
use App\Pdf\Colors\PdfTextColor;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfGroupTable;
use App\Pdf\PdfStyle;
@@ -29,7 +28,7 @@ protected function doRender(array $entities): bool
$this->setTitleTrans('product.list.title');
$this->addPage();
$table = $this->createTable();
- $style = PdfStyle::getCellStyle()
+ $redStyle = PdfStyle::getCellStyle()
->setTextColor(PdfTextColor::red());
$key = '';
@@ -51,7 +50,8 @@ protected function doRender(array $entities): bool
$key = $newKey;
$table->setGroupKey($key);
}
- $style = $this->isFloatZero($entity->getPrice()) ? $style : null;
+
+ $style = $this->isFloatZero($entity->getPrice()) ? $redStyle : null;
$table->startRow()
->add($entity->getDescription())
->addCellAmount($entity->getPrice(), style: $style)
@@ -72,10 +72,10 @@ private function createTable(): PdfGroupTable
{
return PdfGroupTable::instance($this)
->addColumns(
- PdfColumn::left($this->trans('product.fields.description'), 90),
- PdfColumn::right($this->trans('product.fields.price'), 20, true),
- PdfColumn::left($this->trans('product.fields.unit'), 20, true),
- PdfColumn::left($this->trans('product.fields.supplier'), 40, true)
+ $this->leftColumn('product.fields.description', 90),
+ $this->rightColumn('product.fields.price', 20, true),
+ $this->leftColumn('product.fields.unit', 20, true),
+ $this->leftColumn('product.fields.supplier', 40, true)
)->outputHeaders();
}
}
diff --git a/src/Report/SchemaReport.php b/src/Report/SchemaReport.php
index a989c2ff4..4632fe394 100644
--- a/src/Report/SchemaReport.php
+++ b/src/Report/SchemaReport.php
@@ -135,9 +135,9 @@ private function outputAssociations(array $associations): void
}
$table = $this->createTable(
'schema.fields.associations',
- PdfColumn::left($this->trans('schema.fields.name'), 100),
- PdfColumn::left($this->trans('schema.fields.table'), 100),
- PdfColumn::left($this->trans('schema.fields.relation'), 55, true)
+ $this->leftColumn('schema.fields.name', 100),
+ $this->leftColumn('schema.fields.table', 100),
+ $this->leftColumn('schema.fields.relation', 55, true)
);
foreach ($associations as $association) {
$name = $association['table'];
@@ -160,10 +160,10 @@ private function outputColumns(array $columns): void
}
$table = $this->createTable(
'schema.fields.columns',
- PdfColumn::left($this->trans('schema.fields.name'), 100),
- PdfColumn::left($this->trans('schema.fields.type'), 35, true),
- PdfColumn::center($this->trans('schema.fields.required'), 25, true),
- PdfColumn::left($this->trans('schema.fields.default'), 30, true)
+ $this->leftColumn('schema.fields.name', 100),
+ $this->leftColumn('schema.fields.type', 35, true),
+ $this->centerColumn('schema.fields.required', 25, true),
+ $this->leftColumn('schema.fields.default', 30, true)
);
foreach ($columns as $column) {
$link = $this->findLink($column['foreign_table']);
@@ -187,10 +187,10 @@ private function outputIndexes(array $indexes): void
}
$table = $this->createTable(
'schema.fields.indexes',
- PdfColumn::left($this->trans('schema.fields.name'), 100),
- PdfColumn::left($this->trans('schema.fields.columns'), 100),
- PdfColumn::center($this->trans('schema.fields.primary'), 25, true),
- PdfColumn::center($this->trans('schema.fields.unique'), 30, true),
+ $this->leftColumn('schema.fields.name', 100),
+ $this->leftColumn('schema.fields.columns', 100),
+ $this->centerColumn('schema.fields.primary', 25, true),
+ $this->centerColumn('schema.fields.unique', 30, true),
);
foreach ($indexes as $index) {
$table->startRow()
@@ -228,11 +228,11 @@ private function outputTables(array $tables): void
$this->outputTitle('schema.index.title');
$instance = PdfTable::instance($this)
->addColumns(
- PdfColumn::left($this->trans('schema.fields.name'), 100),
- PdfColumn::right($this->trans('schema.fields.columns'), 19, true),
- PdfColumn::right($this->trans('schema.fields.records'), 30, true),
- PdfColumn::right($this->trans('schema.fields.indexes'), 17, true),
- PdfColumn::right($this->trans('schema.fields.associations'), 25, true)
+ $this->leftColumn('schema.fields.name', 100),
+ $this->rightColumn('schema.fields.columns', 19, true),
+ $this->rightColumn('schema.fields.records', 30, true),
+ $this->rightColumn('schema.fields.indexes', 17, true),
+ $this->rightColumn('schema.fields.associations', 25, true)
)->outputHeaders();
foreach ($tables as $table) {
$name = $table['name'];
diff --git a/src/Report/SymfonyReport.php b/src/Report/SymfonyReport.php
index 8da46f9de..cb2c981d0 100644
--- a/src/Report/SymfonyReport.php
+++ b/src/Report/SymfonyReport.php
@@ -97,7 +97,7 @@ private function outputBundles(array $bundles): void
private function outputInfo(SymfonyInfoService $info): void
{
$this->addBookmark('Kernel');
- $app = $this->controller->getApplication();
+ $app = $this->controller->getApplicationService();
$table = PdfGroupTable::instance($this)
->setGroupStyle(PdfStyle::getHeaderStyle())
->addColumns(
diff --git a/src/Report/Table/ReportGroupTable.php b/src/Report/Table/ReportGroupTable.php
index 9c4c43231..4ec6dbee0 100644
--- a/src/Report/Table/ReportGroupTable.php
+++ b/src/Report/Table/ReportGroupTable.php
@@ -15,6 +15,7 @@
use App\Pdf\PdfDocument;
use App\Pdf\PdfGroupTable;
use App\Pdf\Traits\PdfCellTranslatorTrait;
+use App\Pdf\Traits\PdfColumnTranslatorTrait;
use App\Report\AbstractReport;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -24,6 +25,7 @@
class ReportGroupTable extends PdfGroupTable
{
use PdfCellTranslatorTrait;
+ use PdfColumnTranslatorTrait;
/**
* @param PdfDocument $parent the parent document to print in
diff --git a/src/Report/Table/ReportTable.php b/src/Report/Table/ReportTable.php
index 19c21c739..b2ef6a42b 100644
--- a/src/Report/Table/ReportTable.php
+++ b/src/Report/Table/ReportTable.php
@@ -15,6 +15,7 @@
use App\Pdf\PdfDocument;
use App\Pdf\PdfTable;
use App\Pdf\Traits\PdfCellTranslatorTrait;
+use App\Pdf\Traits\PdfColumnTranslatorTrait;
use App\Report\AbstractReport;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -24,6 +25,7 @@
class ReportTable extends PdfTable
{
use PdfCellTranslatorTrait;
+ use PdfColumnTranslatorTrait;
/**
* @param PdfDocument $parent the parent document to print in
diff --git a/src/Report/Table/TableGroups.php b/src/Report/Table/TableGroups.php
index 7a5449f16..4184c8754 100644
--- a/src/Report/Table/TableGroups.php
+++ b/src/Report/Table/TableGroups.php
@@ -14,7 +14,6 @@
use App\Entity\Calculation;
use App\Entity\CalculationGroup;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfStyle;
use App\Report\CalculationReport;
use fpdf\PdfBorder;
@@ -75,11 +74,11 @@ public function startRow(?PdfStyle $style = null): static
private function createColumns(): void
{
$columns = [
- PdfColumn::left($this->trans('report.calculation.resume'), 50),
- PdfColumn::right($this->trans('report.calculation.amount'), 20, true),
- PdfColumn::right($this->trans('report.calculation.margin_percent'), 20, true),
- PdfColumn::right($this->trans('report.calculation.margin_amount'), 20, true),
- PdfColumn::right($this->trans('report.calculation.total'), 20, true),
+ $this->leftColumn('report.calculation.resume', 50),
+ $this->rightColumn('report.calculation.amount', 20, true),
+ $this->rightColumn('report.calculation.margin_percent', 20, true),
+ $this->rightColumn('report.calculation.margin_amount', 20, true),
+ $this->rightColumn('report.calculation.total', 20, true),
];
$this->addColumns(...$columns);
diff --git a/src/Report/Table/TableItems.php b/src/Report/Table/TableItems.php
index 1948a5a15..011e9c6ab 100644
--- a/src/Report/Table/TableItems.php
+++ b/src/Report/Table/TableItems.php
@@ -19,7 +19,6 @@
use App\Pdf\Colors\PdfTextColor;
use App\Pdf\Events\PdfGroupEvent;
use App\Pdf\Interfaces\PdfGroupListenerInterface;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfStyle;
use App\Report\CalculationReport;
use fpdf\PdfBorder;
@@ -162,14 +161,14 @@ private function checkLines(int $lines): void
$this->setInProgress(false);
}
- private function createColumns(): self
+ private function createColumns(): void
{
- return $this->addColumns(
- PdfColumn::left($this->trans('calculationitem.fields.description'), 50),
- PdfColumn::left($this->trans('calculationitem.fields.unit'), 20, true),
- PdfColumn::right($this->trans('calculationitem.fields.price'), 20, true),
- PdfColumn::right($this->trans('calculationitem.fields.quantity'), 20, true),
- PdfColumn::right($this->trans('calculationitem.fields.total'), 20, true)
+ $this->addColumns(
+ $this->leftColumn('calculationitem.fields.description', 50),
+ $this->leftColumn('calculationitem.fields.unit', 20, true),
+ $this->rightColumn('calculationitem.fields.price', 20, true),
+ $this->rightColumn('calculationitem.fields.quantity', 20, true),
+ $this->rightColumn('calculationitem.fields.total', 20, true)
)->outputHeaders();
}
diff --git a/src/Report/Table/TableOverall.php b/src/Report/Table/TableOverall.php
index 0da3c8d9f..b2ec4b4df 100644
--- a/src/Report/Table/TableOverall.php
+++ b/src/Report/Table/TableOverall.php
@@ -14,7 +14,6 @@
use App\Entity\Calculation;
use App\Pdf\Colors\PdfTextColor;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfStyle;
use App\Report\CalculationReport;
use fpdf\PdfBorder;
@@ -80,11 +79,11 @@ public function startRow(?PdfStyle $style = null): static
private function createColumns(): self
{
return $this->addColumns(
- PdfColumn::left(null, 50),
- PdfColumn::right(null, 20, true),
- PdfColumn::right(null, 20, true),
- PdfColumn::right(null, 20, true),
- PdfColumn::right(null, 20, true)
+ $this->leftColumn('', 50),
+ $this->rightColumn('', 20, true),
+ $this->rightColumn('', 20, true),
+ $this->rightColumn('', 20, true),
+ $this->rightColumn('', 20, true),
)->setRepeatHeader(false);
}
@@ -99,7 +98,7 @@ private function outputGlobalMargin(float $globalMargin, float $globalAmount): s
->endRow();
}
- private function outputOverallTotal(Calculation $calculation, float $totalItems): self
+ private function outputOverallTotal(Calculation $calculation, float $totalItems): void
{
$style = null;
if ($calculation->isMarginBelow($this->minMargin)) {
@@ -112,8 +111,6 @@ private function outputOverallTotal(Calculation $calculation, float $totalItems)
->addCellAmount($calculation->getOverallMarginAmount())
->addCellAmount($calculation->getOverallTotal())
->endRow();
-
- return $this;
}
private function outputUserMargin(float $userMargin, float $userAmount, float $totalNet): self
diff --git a/src/Report/TasksReport.php b/src/Report/TasksReport.php
index ae3c00684..19b713ef8 100644
--- a/src/Report/TasksReport.php
+++ b/src/Report/TasksReport.php
@@ -111,11 +111,11 @@ private function createTable(): ReportGroupTable
return ReportGroupTable::fromReport($this)
->addColumns(
PdfColumn::left($name, 40),
- PdfColumn::left($this->trans('task.fields.category'), 50, true),
- PdfColumn::left($this->trans('task.fields.unit'), 15, true),
- PdfColumn::right($this->trans('taskitemmargin.fields.minimum'), 20, true),
- PdfColumn::right($this->trans('taskitemmargin.fields.maximum'), 20, true),
- PdfColumn::right($this->trans('taskitemmargin.fields.value'), 20, true)
+ $this->leftColumn('task.fields.category', 50, true),
+ $this->leftColumn('task.fields.unit', 15, true),
+ $this->rightColumn('taskitemmargin.fields.minimum', 20, true),
+ $this->rightColumn('taskitemmargin.fields.maximum', 20, true),
+ $this->rightColumn('taskitemmargin.fields.value', 20, true)
)->outputHeaders()
->setGroupListener($this);
}
diff --git a/src/Report/UsersReport.php b/src/Report/UsersReport.php
index 46735d1cd..ea4f5ffaa 100644
--- a/src/Report/UsersReport.php
+++ b/src/Report/UsersReport.php
@@ -16,7 +16,6 @@
use App\Entity\User;
use App\Pdf\Colors\PdfTextColor;
use App\Pdf\PdfCell;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfImageCell;
use App\Pdf\PdfStyle;
use App\Pdf\PdfTable;
@@ -60,12 +59,12 @@ private function createTable(): PdfTable
{
return PdfTable::instance($this)
->addColumns(
- PdfColumn::center($this->trans('user.fields.imageFile'), 18, true),
- PdfColumn::left($this->trans('user.fields.username'), 25),
- PdfColumn::left($this->trans('user.fields.email'), 30),
- PdfColumn::left($this->trans('user.fields.role'), 35, true),
- PdfColumn::left($this->trans('user.fields.enabled'), 18, true),
- PdfColumn::left($this->trans('user.fields.lastLogin'), 30, true)
+ $this->centerColumn('user.fields.imageFile', 18, true),
+ $this->leftColumn('user.fields.username', 25),
+ $this->leftColumn('user.fields.email', 30),
+ $this->leftColumn('user.fields.role', 35, true),
+ $this->leftColumn('user.fields.enabled', 18, true),
+ $this->leftColumn('user.fields.lastLogin', 30, true)
)->outputHeaders();
}
diff --git a/src/Report/UsersRightsReport.php b/src/Report/UsersRightsReport.php
index 1a51e59a7..885de6aa0 100644
--- a/src/Report/UsersRightsReport.php
+++ b/src/Report/UsersRightsReport.php
@@ -19,7 +19,6 @@
use App\Model\Role;
use App\Pdf\Events\PdfGroupEvent;
use App\Pdf\Interfaces\PdfGroupListenerInterface;
-use App\Pdf\PdfColumn;
use App\Pdf\PdfGroupTable;
use App\Pdf\PdfStyle;
use App\Pdf\PdfTable;
@@ -117,10 +116,10 @@ private function createTableBuilder(): PdfGroupTable
$table = PdfGroupTable::instance($this)
->setGroupStyle(PdfStyle::getCellStyle()->setFontBold())
->setGroupListener($this)
- ->addColumn(PdfColumn::left($this->trans('user.rights.table_title'), 50));
+ ->addColumn($this->leftColumn('user.rights.table_title', 50));
$permissions = EntityPermission::sorted();
foreach ($permissions as $permission) {
- $table->addColumn(PdfColumn::center($this->trans($permission), 25, true));
+ $table->addColumn($this->centerColumn($permission, 25, true));
}
$table->outputHeaders();
@@ -129,7 +128,7 @@ private function createTableBuilder(): PdfGroupTable
private function getApplication(): ApplicationService
{
- return $this->controller->getApplication();
+ return $this->controller->getApplicationService();
}
/**
diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php
index 8db4a2061..9938a1dc6 100644
--- a/src/Repository/AbstractRepository.php
+++ b/src/Repository/AbstractRepository.php
@@ -118,7 +118,7 @@ public function getDistinctValues(string $field, string $value = '', int $limit
/**
* Gets the database search fields.
*
- * The default implementation returns the alias and the field separated by a dot ('.') character.
+ * The default implementation returns the alias and the field separated by a dot character ('.').
*
* @param string $field the field name
* @param string $alias the entity alias
@@ -186,7 +186,7 @@ public function getSingleIdentifierFieldName(): string
/**
* Gets the database sort field.
*
- * The default implementation returns the alias and the field separated by a dot ('.') character.
+ * The default implementation returns the alias and the field separated by a dot character ('.').
*
* @param string $field the field name
* @param string $alias the entity alias
diff --git a/src/Repository/CalculationStateRepository.php b/src/Repository/CalculationStateRepository.php
index 8524a0964..f62f1ce48 100644
--- a/src/Repository/CalculationStateRepository.php
+++ b/src/Repository/CalculationStateRepository.php
@@ -59,7 +59,7 @@ public function __construct(ManagerRegistry $registry)
}
/**
- * Gets states with calculations statistics.
+ * Gets states with the calculation statistics.
*
* Note: Only states with at least one calculation are returned.
*
diff --git a/src/Repository/CustomerRepository.php b/src/Repository/CustomerRepository.php
index 6d98a01ba..949172984 100644
--- a/src/Repository/CustomerRepository.php
+++ b/src/Repository/CustomerRepository.php
@@ -48,7 +48,7 @@ public function __construct(ManagerRegistry $registry)
}
/**
- * Gets all customers order by name and company.
+ * Gets all the customers order by name and company.
*
* @return Customer[]
*/
diff --git a/src/Repository/GlobalMarginRepository.php b/src/Repository/GlobalMarginRepository.php
index 2f91bfcc1..c1b2d11c2 100644
--- a/src/Repository/GlobalMarginRepository.php
+++ b/src/Repository/GlobalMarginRepository.php
@@ -30,7 +30,7 @@ public function __construct(ManagerRegistry $registry)
}
/**
- * Gets all global margins order by minimum.
+ * Gets all global margins ordered by the minimum.
*
* @return GlobalMargin[]
*/
diff --git a/src/Repository/GroupRepository.php b/src/Repository/GroupRepository.php
index 2bcdb3506..6053f1459 100644
--- a/src/Repository/GroupRepository.php
+++ b/src/Repository/GroupRepository.php
@@ -48,7 +48,7 @@ public function __construct(ManagerRegistry $registry)
}
/**
- * Gets all group order by code.
+ * Gets all group ordered by code.
*
* @return Group[]
*/
diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php
index bf7b305bc..764b99049 100644
--- a/src/Repository/ProductRepository.php
+++ b/src/Repository/ProductRepository.php
@@ -48,7 +48,7 @@ public function findByCategory(Category $category): array
}
/**
- * Gets all products order by description.
+ * Gets all products ordered by description.
*
* @return Product[]
*/
@@ -58,7 +58,7 @@ public function findByDescription(): array
}
/**
- * Gets all products order by group, category and description.
+ * Gets all products ordered by the group, the category and the description.
*
* @return Product[]
*/
@@ -77,7 +77,7 @@ public function findByGroup(): array
}
/**
- * Gets the default query builder with all products order by the category code, the group code and the
+ * Gets the default query builder with all products ordered by the category code, the group code, and the
* product description.
*/
public function getQueryBuilderByCategory(): QueryBuilder
diff --git a/src/Repository/TaskItemRepository.php b/src/Repository/TaskItemRepository.php
index 3f44d7e98..f356239fa 100644
--- a/src/Repository/TaskItemRepository.php
+++ b/src/Repository/TaskItemRepository.php
@@ -16,7 +16,7 @@
use Doctrine\Persistence\ManagerRegistry;
/**
- * Repository for task item entity.
+ * Repository for the task item entity.
*
* @template-extends AbstractRepositorytrue to send the file inline to the browser. The document viewer is
- * used if available. false to send to the browser and force a file
- * download with the name given.
+ * @param bool $inline true to send the file inline to the browser.
+ * The document viewer is used if available.
+ * false to send to the browser and force a file download with the name
+ * given.
* @param string $name the name of the document file or '' to use the default
* name ('document.csv')
*/
diff --git a/src/Response/PdfResponse.php b/src/Response/PdfResponse.php
index b94ae49a4..ea5835728 100644
--- a/src/Response/PdfResponse.php
+++ b/src/Response/PdfResponse.php
@@ -24,9 +24,10 @@ class PdfResponse extends AbstractStreamedResponse
{
/**
* @param PdfDocument $doc the document to output
- * @param bool $inline true to send the file inline to the browser. The document viewer
- * is used if available. false to send to the browser and force a file
- * download with the name given.
+ * @param bool $inline true to send the file inline to the browser.
+ * The document viewer is used if available.
+ * false to send to the browser and force a file download with the name
+ * given.
* @param string $name the name of the document file or '' to use the default name
* ('document.pdf').
*/
diff --git a/src/Response/SpreadsheetResponse.php b/src/Response/SpreadsheetResponse.php
index 83daa6bb8..bc0ca349a 100644
--- a/src/Response/SpreadsheetResponse.php
+++ b/src/Response/SpreadsheetResponse.php
@@ -24,10 +24,10 @@ class SpreadsheetResponse extends AbstractStreamedResponse
{
/**
* @param SpreadsheetDocument $doc the document to output
- * @param bool $inline true to send the file inline to the browser. The document viewer
- * is used if available. false to send to the browser and force
- * a file
- * download with the name given.
+ * @param bool $inline true to send the file inline to the browser.
+ * The document viewer is used if available.
+ * false to send to the browser and force a file download with
+ * the name given.
* @param string $name the name of the document file or '' to use the default
* name ('document.xlsx')
*/
diff --git a/src/Response/WordResponse.php b/src/Response/WordResponse.php
index 528ae55db..86fb086ac 100644
--- a/src/Response/WordResponse.php
+++ b/src/Response/WordResponse.php
@@ -22,9 +22,10 @@ class WordResponse extends AbstractStreamedResponse
{
/**
* @param WordDocument $doc the document to output
- * @param bool $inline true to send the file inline to the browser. The document viewer is
- * used if available. false to send to the browser and force a file
- * download with the name given.
+ * @param bool $inline true to send the file inline to the browser.
+ * The document viewer is used if available.
+ * false to send to the browser and force a file download with the name
+ * given.
* @param string $name the name of the document file or '' to use the default
* name ('document.docx')
*/
diff --git a/src/Service/AES256EncryptorService.php b/src/Service/AES256EncryptorService.php
index a6515b052..d45c01d99 100644
--- a/src/Service/AES256EncryptorService.php
+++ b/src/Service/AES256EncryptorService.php
@@ -59,7 +59,7 @@ public function decrypt(string $data): string|false
}
/**
- * @throws \JsonException if the data can not be decoded
+ * @throws \JsonException if the data cannot be decoded
*/
public function decryptJson(string $data, bool $assoc = true, int $flags = 0): mixed
{
@@ -89,7 +89,7 @@ public function encrypt(string $data): string|false
}
/**
- * @throws \JsonException if the data can not be encoded
+ * @throws \JsonException if the data cannot be encoded
*/
public function encryptJson(mixed $data, int $flags = 0): string|false
{
diff --git a/src/Service/AkismetService.php b/src/Service/AkismetService.php
index 9656d7ab6..a1daf9fa7 100644
--- a/src/Service/AkismetService.php
+++ b/src/Service/AkismetService.php
@@ -23,7 +23,7 @@
use Symfony\Contracts\Translation\TranslatorInterface;
/**
- * Service to check spams with the Akismet.
+ * Service to check spamming with the Akismet.
*
* @see https://akismet.com/
*/
@@ -89,9 +89,11 @@ public function getCacheTimeout(): int
* The parameters options can be one of the following:
*
* Janvier
* Février
@@ -143,7 +143,7 @@ public static function getMonths(): array
/**
* Gets the localized short month names.
- * For example with 'fr' as locale, return
+ * For example, with 'fr' as locale, return
*
* Janv.
* Févr.
@@ -163,7 +163,7 @@ public static function getShortMonths(): array
/**
* Gets the localized short week day names.
- * For example with 'fr' as locale and 'sunday' as first day, return
+ * For example, with 'fr' as locale and 'sunday' as first day, return
*
* Dim.
* Lun.
@@ -171,7 +171,7 @@ public static function getShortMonths(): array
* ...
* .
*
- * @param string $firstDay The first day of the week, in english, like 'sunday' or 'monday'
+ * @param string $firstDay The first day of the week, in english, like 'sunday' or 'monday'
*
* @return array
*/
@@ -189,7 +189,7 @@ public static function getShortWeekdays(string $firstDay = 'monday'): array
*
* The weeks are starting on Monday.
*
- * @return int a value 1 through 53
+ * @return int value 1 through 53
*/
public static function getWeek(\DateTimeInterface $date): int
{
@@ -198,7 +198,7 @@ public static function getWeek(\DateTimeInterface $date): int
/**
* Gets the localized week day names.
- * For example with 'fr' as locale and 'sunday' as first day, return
+ * For example, with 'fr' as locale and 'sunday' as first day, return
*
* Dimanche
* Lundi
@@ -220,7 +220,7 @@ public static function getWeekdays(string $firstDay = 'monday'): array
}
/**
- * Gets the full numeric representation of a year with 4 digit for the given date.
+ * Gets the full numeric representation of a year with 4 digits for the given date.
*/
public static function getYear(\DateTimeInterface $date): int
{
diff --git a/src/Utils/FileUtils.php b/src/Utils/FileUtils.php
index 4e446b575..d8b73ae62 100644
--- a/src/Utils/FileUtils.php
+++ b/src/Utils/FileUtils.php
@@ -97,7 +97,7 @@ public static function decodeJson(string|\SplFileInfo $file, bool $assoc = true)
// file or url?
if (!self::isFile($file) && false === \filter_var($file, \FILTER_VALIDATE_URL)) {
- throw new \InvalidArgumentException(\sprintf("The file '%s' can not be found.", $file));
+ throw new \InvalidArgumentException(\sprintf("The file '%s' cannot be found.", $file));
}
$content = \file_get_contents($file);
if (false === $content) {
@@ -160,7 +160,7 @@ public static function formatSize(string|\SplFileInfo|int $path): string
}
/**
- * Returns the extension from a file path (without leading dot).
+ * Returns the extension from a file path (without the leading dot).
*
* @param bool $forceLowerCase forces the extension to be lower-case
*/
diff --git a/src/Utils/ReverseReader.php b/src/Utils/ReverseReader.php
index d1c255aa1..fcc3ed572 100644
--- a/src/Utils/ReverseReader.php
+++ b/src/Utils/ReverseReader.php
@@ -20,7 +20,7 @@
*
* $reader = new ReverseReader("path/to/file_name.txt");
* foreach ($reader as $data) {
- * echo $data ."\n";
+ * echo $data . "\n";
* }
*
*
diff --git a/src/Word/AbstractWordDocument.php b/src/Word/AbstractWordDocument.php
index eb199a5e6..20a07f73c 100644
--- a/src/Word/AbstractWordDocument.php
+++ b/src/Word/AbstractWordDocument.php
@@ -43,7 +43,7 @@ public function __construct(protected readonly AbstractController $controller)
{
parent::__construct();
$this->translator = $this->controller->getTranslator();
- $this->customer = $this->controller->getApplication()->getCustomer();
+ $this->customer = $this->controller->getApplicationService()->getCustomer();
$this->printAddress = $this->controller->getUserService()->isPrintAddress();
$this->header = new WordHeader($this);
$this->footer = new WordFooter($this);
@@ -78,7 +78,7 @@ public function setPrintAddress(bool $printAddress): static
/**
* Sets the title to be translated.
*
- * @param string $id the message id (may also be an object that can be cast to string)
+ * @param string $id the message identifier (may also be an object that can be cast to string)
* @param array $parameters an array of parameters for the message
* @param ?string $domain the domain for the message or null to use the default
*/
@@ -144,7 +144,7 @@ protected function initialize(): void
if (null !== $user) {
$properties->setCreator($user);
}
- $customer = $this->controller->getApplication()->getCustomerName();
+ $customer = $this->controller->getApplicationService()->getCustomerName();
if (null !== $customer) {
$properties->setCompany($customer);
}
diff --git a/src/Word/HtmlWordParser.php b/src/Word/HtmlWordParser.php
index b9d9e4633..2d7dd8a3d 100644
--- a/src/Word/HtmlWordParser.php
+++ b/src/Word/HtmlWordParser.php
@@ -174,7 +174,7 @@ private function parseBorders(string $class): string
}
/**
- * Parses the margins class.
+ * Parses margins class.
*/
private function parseMargins(string $class): string
{
diff --git a/src/Word/WordFooter.php b/src/Word/WordFooter.php
index 347f16127..dbdbdb418 100644
--- a/src/Word/WordFooter.php
+++ b/src/Word/WordFooter.php
@@ -21,7 +21,7 @@
/**
* Class to output footer in Word documents.
*
- * This footer add the following texts:
+ * This footer adds the following texts:
*
* - The current and total pages at the left.
* - The application name at the center
diff --git a/src/Word/WordHeader.php b/src/Word/WordHeader.php
index 71eace160..cd6ff0afd 100644
--- a/src/Word/WordHeader.php
+++ b/src/Word/WordHeader.php
@@ -22,14 +22,14 @@
/**
* Class to output header in Word documents.
*
- * This header add the following texts, depending on the printing address state:
+ * This header adds the following texts, depending on the printing address state:
*
* - The customer's name at the left and the address if applicable.
* - The document's title at the center, if applicable; at the right else.
* - The phone, the fax and the email at the right if applicable.
*
*
- * Do nothing if the document's title and the customer's name are empty.
+ * Do nothing if the document's title and the customer's name is empty.
*/
class WordHeader extends AbstractHeaderFooter
{
diff --git a/templates/admin/archive_result.html.twig b/templates/admin/archive_result.html.twig
index 3d8c7c027..d4ca6e812 100644
--- a/templates/admin/archive_result.html.twig
+++ b/templates/admin/archive_result.html.twig
@@ -52,7 +52,8 @@