diff --git a/app/src/Commands/AbstractCliCommand.php b/app/src/Commands/AbstractCliCommand.php
new file mode 100644
index 0000000..c158467
--- /dev/null
+++ b/app/src/Commands/AbstractCliCommand.php
@@ -0,0 +1,31 @@
+configuration = $configuration;
+ parent::__construct($name);
+ }
+}
diff --git a/app/src/Commands/InvoiceCommand.php b/app/src/Commands/InvoiceCommand.php
index 286f924..43823bf 100644
--- a/app/src/Commands/InvoiceCommand.php
+++ b/app/src/Commands/InvoiceCommand.php
@@ -38,8 +38,8 @@ use function var_export;
/**
* Main file - invoice command.
*/
-class InvoiceCommand extends Command {
-
+class InvoiceCommand extends Command
+{
use SelectReportTrait;
protected $csv;
@@ -50,8 +50,8 @@ class InvoiceCommand extends Command {
protected $pdfExport;
- const TYPE_WORK = 1;
- const TYPE_EXPENSE = 2;
+ protected const TYPE_WORK = 1;
+ protected const TYPE_EXPENSE = 2;
public function __construct(
ReportCsvInterface $csv,
@@ -61,18 +61,18 @@ class InvoiceCommand extends Command {
MailerInterface $mailer,
?string $name = null
) {
- $this->csv = $csv;
- $this->config = $configuration;
- $this->trackingService = $trackingService;
- $this->pdfExport = $pdf_export;
- $this->mailer = $mailer;
+ $this->csv = $csv;
+ $this->config = $configuration;
+ $this->trackingService = $trackingService;
+ $this->pdfExport = $pdf_export;
+ $this->mailer = $mailer;
parent::__construct($name);
}
/**
* Get configuration.
*/
- protected function configure() : void
+ protected function configure(): void
{
$this->setName('invoice');
$this->setDescription('Generate an invoice from (monthly) report');
@@ -124,6 +124,7 @@ class InvoiceCommand extends Command {
'expenses',
'e',
InputOption::VALUE_OPTIONAL,
+ // phpcs:ignore
'List of additional expenses in format expense1=value1;expenses2=value2... or empty for interactive output.',
false
);
@@ -131,6 +132,7 @@ class InvoiceCommand extends Command {
'custom',
'c',
InputOption::VALUE_OPTIONAL,
+ // phpcs:ignore
'Additional custom work untracked in format: name1=time1;name2=time2... Project to assign work items to has to be configured in app config. Leave empty for interactive output.',
false
);
@@ -149,7 +151,7 @@ class InvoiceCommand extends Command {
);
}
- protected function execute(InputInterface $input, OutputInterface $output) : int
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
if ($input->getOption('test')) {
$test = $this->trackingService->testYoutrackapi();
@@ -161,9 +163,7 @@ class InvoiceCommand extends Command {
return Command::SUCCESS;
}
// Gets report parameter.
- $this->getReportParameter($input, $output, 'tracking_service.youtrack.invoice.report');
- $report_id = $this->trackingService->getReportId();
- $file = $this->getReportCsvFilePath($input, $output, $report_id);
+ $file = $this->getReportCsvFilePath($input, $output, 'tracking_service.youtrack.invoice.report');
$report_name = $this->trackingService->getReportName();
if ($input->hasParameterOption('--expenses') || $input->hasParameterOption('-e')) {
$expenses = $this->getCustomWorkOrExpenses($input->getOption('expenses'), self::TYPE_EXPENSE);
@@ -202,7 +202,7 @@ class InvoiceCommand extends Command {
return Command::SUCCESS;
}
- protected function getTable(OutputInterface $output, array $data) : Table
+ protected function getTable(OutputInterface $output, array $data): Table
{
$rows = $this->csv->generateTable($data);
$table = new Table($output);
@@ -230,7 +230,7 @@ class InvoiceCommand extends Command {
* @deprecated
* This method was almost exact copy of CsvReport::arangeDataForDefaultPdfExport
*/
- protected function generateTable(OutputInterface $output, array $data) : Table
+ protected function generateTable(OutputInterface $output, array $data): Table
{
$table = new Table($output);
$table->setHeaders([
@@ -282,7 +282,7 @@ class InvoiceCommand extends Command {
/**
* Dummy output for testing.
*/
- protected function dummyOutput(InputInterface $input, OutputInterface $output) : void
+ protected function dummyOutput(InputInterface $input, OutputInterface $output): void
{
// $txt = $this->translator->trans('From [start-date] to [end-date].', [], 'rprt', 'sl_SI');
// $output->writeln($txt);
@@ -326,7 +326,8 @@ class InvoiceCommand extends Command {
return $output;
}
- protected function getCustomWorkOrExpenses($custom, $type) {
+ protected function getCustomWorkOrExpenses($custom, $type)
+ {
$output = [];
if (is_string($custom)) {
foreach (explode(';', $custom) as $item) {
diff --git a/app/src/Commands/ReportCommand.php b/app/src/Commands/ReportCommand.php
index f61d56d..c6cb386 100644
--- a/app/src/Commands/ReportCommand.php
+++ b/app/src/Commands/ReportCommand.php
@@ -18,8 +18,8 @@ use Symfony\Component\Console\Output\OutputInterface;
use function is_array;
use function is_null;
-class ReportCommand extends Command {
-
+class ReportCommand extends Command
+{
use SelectReportTrait;
protected $trackingService;
@@ -28,6 +28,7 @@ class ReportCommand extends Command {
protected $csv;
+ // phpcs:ignore
public function __construct(ConfigurationInterface $configuration, YoutrackInterface $tracking_service, ReportCsvInterface $csv, ?string $name = null)
{
$this->config = $configuration;
@@ -37,7 +38,8 @@ class ReportCommand extends Command {
parent::__construct($name);
}
- protected function configure() : void {
+ protected function configure(): void
+ {
$this->setName('report');
$this->setDescription('Get a time-tracking report into command line.');
$this->addOption(
@@ -63,7 +65,7 @@ class ReportCommand extends Command {
);
}
- protected function execute(InputInterface $input, OutputInterface $output) : int
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
if ($timeRange = $input->getOption('time-range')) {
// @TODO: Implement time range option:
@@ -77,10 +79,8 @@ class ReportCommand extends Command {
$output->writeln('This option is not supported yet.');
return Command::FAILURE;
}
- $this->getReportParameter($input, $output);
// Currently we only support csv download.
- $report_id = $this->trackingService->getReportId();
- $file = $this->getReportCsvFilePath($input, $output, $report_id);
+ $file = $this->getReportCsvFilePath($input, $output);
$report_name = $this->trackingService->getReportName();
$output->writeln("report: {$report_name}");
$data = $this->csv->generateReportTable($file);
@@ -95,7 +95,7 @@ class ReportCommand extends Command {
*
* @TODO: Code duplication with InvoiceCommand::getTable.
*/
- protected function buildTable(OutputInterface $output, array $rows) : Table
+ protected function buildTable(OutputInterface $output, array $rows): Table
{
$table = new Table($output);
$table->setHeaders([
@@ -109,7 +109,10 @@ class ReportCommand extends Command {
$rows[$key] = new TableSeparator();
} elseif (is_array($row) && is_null($row[0]) && is_null($row[2])) {
// Check which elements in array are null.
- $rows[$key] = [new TableCell($row[1], ['colspan' => 2]), new TableCell((string) $row[3], ['colspan' => 2])];
+ $rows[$key] = [
+ new TableCell($row[1], ['colspan' => 2]),
+ new TableCell((string) $row[3], ['colspan' => 2]),
+ ];
}
}
$table->setRows($rows);
diff --git a/app/src/Commands/SelectReportTrait.php b/app/src/Commands/SelectReportTrait.php
index bcf26bf..28414c5 100644
--- a/app/src/Commands/SelectReportTrait.php
+++ b/app/src/Commands/SelectReportTrait.php
@@ -9,6 +9,8 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
+use function array_flip;
+
/**
* Trait to select report.
*
@@ -16,17 +18,22 @@ use Symfony\Component\Console\Question\ChoiceQuestion;
* Command must have report input option. It is not the most elegant solution
* but it helps avoiding code duplication.
*/
-trait SelectReportTrait {
-
- protected function checkContext() {
- if (!isset($this->trackingService)) {
- return FALSE;
+trait SelectReportTrait
+{
+ protected function checkContext()
+ {
+ if (! isset($this->trackingService)) {
+ return false;
}
return $this instanceof Command;
}
- protected function getReportParameter(InputInterface $input, OutputInterface $output, $default = 'tracking_service.youtrack.report.report') {
- if (!$this->checkContext()) {
+ protected function getReportParameter(
+ InputInterface $input,
+ OutputInterface $output,
+ $default = 'tracking_service.youtrack.report.report'
+ ) {
+ if (! $this->checkContext()) {
return Command::FAILURE;
}
$reports = $this->trackingService->listReports();
@@ -38,8 +45,8 @@ trait SelectReportTrait {
$helper = $this->getHelper('question');
$question = new ChoiceQuestion('Select report:', $reports);
$question
- ->setErrorMessage('Report %s does not exist!')
- ->setAutocompleterValues($reports);
+ ->setErrorMessage('Report %s does not exist!')
+ ->setAutocompleterValues($reports);
$report_id = $helper->ask($input, $output, $question);
$output->writeln('Report ' . $report_id . ' selected.');
}
@@ -60,8 +67,14 @@ trait SelectReportTrait {
$this->trackingService->setReportName();
}
- protected function getReportCsvFilePath(InputInterface $input, OutputInterface $output, ?string $report_id) : ?string {
- if (!$file = $input->getOption('file')) {
+ protected function getReportCsvFilePath(
+ InputInterface $input,
+ OutputInterface $output,
+ ?string $default = 'tracking_service.youtrack.report.report'
+ ): ?string {
+ if (! $file = $input->getOption('file')) {
+ $this->getReportParameter($input, $output, $default);
+ $report_id = $this->trackingService->getReportId();
$cache_clear_status = $this->trackingService->clearReportCache($report_id);
if ($output->isVerbose()) {
$output->writeln("Report {$report_id} cache cleared, status: {$cache_clear_status}");
@@ -75,6 +88,4 @@ trait SelectReportTrait {
}
return $file;
}
-
}
-
diff --git a/app/src/Commands/TrackCommand.php b/app/src/Commands/TrackCommand.php
index 1443271..538030e 100644
--- a/app/src/Commands/TrackCommand.php
+++ b/app/src/Commands/TrackCommand.php
@@ -30,10 +30,11 @@ class TrackCommand extends Command
parent::__construct($name);
}
- protected function configure() : void
+ protected function configure(): void
{
$this->setName('youtrack');
$this->setDescription('Track time into your youtrack service');
+ // phpcs:ignore
$this->addUsage('rprt-cli youtrack --issue=[issue-name] --minutes=[minutes] --date=[days-ago] --description=[text] --work-type=[work-type]');
// Options or arguments? Technically they are arguments but default value could be provided by config.
// Options are more suitable.
diff --git a/app/src/Utils/Configuration/ConfigurationInterface.php b/app/src/Utils/Configuration/ConfigurationInterface.php
index b8ee77b..75e6793 100644
--- a/app/src/Utils/Configuration/ConfigurationInterface.php
+++ b/app/src/Utils/Configuration/ConfigurationInterface.php
@@ -11,7 +11,7 @@ interface ConfigurationInterface
/**
* Get and read the configuration from file.
*/
- public function getConfig() : bool;
+ public function getConfig(): bool;
/**
* Get a specific configuration for key.
@@ -31,5 +31,5 @@ interface ConfigurationInterface
* @param string $key
* Key to check for.
*/
- public function exists($key) : bool;
+ public function exists($key): bool;
}
diff --git a/app/src/Utils/Configuration/ConfigurationService.php b/app/src/Utils/Configuration/ConfigurationService.php
index 4543ae1..064ae23 100644
--- a/app/src/Utils/Configuration/ConfigurationService.php
+++ b/app/src/Utils/Configuration/ConfigurationService.php
@@ -69,7 +69,7 @@ class ConfigurationService implements ConfigurationInterface
return $fullPath;
}
}
- // @TODO This should be some kind of error!
+ // @TODO This should be some kind of error!
var_dump('Config File Not Found!');
return false;
}
@@ -77,7 +77,7 @@ class ConfigurationService implements ConfigurationInterface
/**
* Get and read the configuration from file.
*/
- public function getConfig() : bool
+ public function getConfig(): bool
{
if ($this->configFilePath) {
$config = Yaml::parseFile($this->configFilePath);
@@ -125,7 +125,7 @@ class ConfigurationService implements ConfigurationInterface
*
* Value of configuration key is not equal to default.
*/
- public function exists($key) : bool
+ public function exists($key): bool
{
return $this->get($key) !== $this->default;
}
diff --git a/app/src/Utils/Configuration/TranslationService.php b/app/src/Utils/Configuration/TranslationService.php
index 997048c..9618fb1 100644
--- a/app/src/Utils/Configuration/TranslationService.php
+++ b/app/src/Utils/Configuration/TranslationService.php
@@ -4,6 +4,8 @@ declare(strict_types=1);
// src/Utils/Configuration/TranslationService.php
+namespace RprtCli\Utils\Translation;
+
use RprtCli\Utils\Configuration\ConfigurationInterface;
class TranslationService
diff --git a/app/src/Utils/CsvReport/CsvReport.php b/app/src/Utils/CsvReport/CsvReport.php
index c05ca58..a36be37 100644
--- a/app/src/Utils/CsvReport/CsvReport.php
+++ b/app/src/Utils/CsvReport/CsvReport.php
@@ -39,7 +39,7 @@ class CsvReport implements CsvReportInterface
/**
* {@inheritdoc}
*/
- public function getInvoiceData(string $filePath) : array
+ public function getInvoiceData(string $filePath): array
{
$output = [];
// @TODO replace with config service.
@@ -69,7 +69,7 @@ class CsvReport implements CsvReportInterface
*
* Project key and unit of time spent.
*/
- protected function parseCsvFile(array $rawData) : array
+ protected function parseCsvFile(array $rawData): array
{
$config = $this->configurationService->get('projects');
foreach ($config as $key => $project) {
@@ -80,7 +80,7 @@ class CsvReport implements CsvReportInterface
return [];
}
- public function arangeDataForDefaultPdfExport(array $data) : array
+ public function arangeDataForDefaultPdfExport(array $data): array
{
[$rows, $totalHours, $totalPrice] = [[], 0, 0];
$projectsConfig = $this->configurationService->get('projects');
@@ -111,13 +111,18 @@ class CsvReport implements CsvReportInterface
}
// @TODO Check rate in final result.
// $rows[] = [$this->translator->trans('Sum'), $totalHours, $config['price'], $totalPrice];
- $rows[] = ['Gesamt netto', number_format($totalHours, 2, ',', '.'), number_format($config['price'], 2, ',', '.'), number_format($totalPrice, 2, ',', '.')];
+ $rows[] = [
+ 'Gesamt netto',
+ number_format($totalHours, 2, ',', '.'),
+ number_format($config['price'], 2, ',', '.'),
+ number_format($totalPrice, 2, ',', '.')
+ ];
$rows[] = [null, null, 'Gessamt brutto', number_format($totalPrice, 2, ',', '.')];
return $rows;
}
- protected function dummyConfig() : array
+ protected function dummyConfig(): array
{
return [
'projects' => [
@@ -127,15 +132,15 @@ class CsvReport implements CsvReportInterface
'price' => 26,
// optional specify columns
],
- 'WV' => [
- 'name' => 'Wirtschaftsverlag',
- 'pattern' => 'WV-[0-9]+',
+ 'TNP' => [
+ 'name' => 'Triglav National Park',
+ 'pattern' => 'TNP-[0-9]+',
'price' => 26,
// optional specify columns
],
'Other' => [
'name' => 'Other projects',
- 'pattern' => '(?!.\bLDP\b)(?!.\bWV\b)',
+ 'pattern' => '(?!.\bLDP\b)(?!.\bTNP\b)',
'price' => 26,
// optional specify columns
],
diff --git a/app/src/Utils/CsvReport/CsvReportInterface.php b/app/src/Utils/CsvReport/CsvReportInterface.php
index 4db4596..91ee52e 100644
--- a/app/src/Utils/CsvReport/CsvReportInterface.php
+++ b/app/src/Utils/CsvReport/CsvReportInterface.php
@@ -17,7 +17,7 @@ interface CsvReportInterface
*
* Project key as key and number of hours as value.
*/
- public function getInvoiceData(string $filePath) : array;
+ public function getInvoiceData(string $filePath): array;
/**
* Data for default drunomics pdf export.
@@ -25,5 +25,5 @@ interface CsvReportInterface
*
* Parsed data from csv report.
*/
- public function arangeDataForDefaultPdfExport(array $data) : array;
+ public function arangeDataForDefaultPdfExport(array $data): array;
}
diff --git a/app/src/Utils/CsvReport/ReportCsv.php b/app/src/Utils/CsvReport/ReportCsv.php
index d17823a..89e9eec 100644
--- a/app/src/Utils/CsvReport/ReportCsv.php
+++ b/app/src/Utils/CsvReport/ReportCsv.php
@@ -46,7 +46,7 @@ class ReportCsv implements ReportCsvInterface
/**
* {@inheritdoc}
*/
- public function getInvoiceData(string $filePath) : array
+ public function getInvoiceData(string $filePath): array
{
$output = [];
// @TODO replace with config service.
@@ -80,7 +80,7 @@ class ReportCsv implements ReportCsvInterface
*
* Project key and unit of time spent.
*/
- protected function parseCsvFile(array $rawData) : array
+ protected function parseCsvFile(array $rawData): array
{
$config = $this->configurationService->get('projects');
foreach ($config as $key => $project) {
@@ -94,7 +94,7 @@ class ReportCsv implements ReportCsvInterface
/**
* Input is array of Work elements and expenses.
*/
- public function generateTable(array $data) : array
+ public function generateTable(array $data): array
{
[$rows, $totalHours, $totalPrice, $add_separator] = [[], 0, 0, false];
$projectsConfig = $this->configurationService->get('projects');
@@ -126,8 +126,13 @@ class ReportCsv implements ReportCsvInterface
}
if ($add_separator) {
// @TODO replace separators with constants for normal separating.
- $rows[] = null;
- $rows[] = ['Gesamt netto', number_format($totalHours, 2, ',', '.'), ' ', number_format($totalPrice, 2, ',', '.')];
+ $rows[] = null;
+ $rows[] = [
+ 'Gesamt netto',
+ number_format($totalHours, 2, ',', '.'),
+ ' ',
+ number_format($totalPrice, 2, ',', '.')
+ ];
$add_separator = false;
}
if (empty($data)) {
@@ -168,7 +173,7 @@ class ReportCsv implements ReportCsvInterface
/**
* {@inheritdoc}
*/
- public function arangeDataForDefaultPdfExport(array $data) : array
+ public function arangeDataForDefaultPdfExport(array $data): array
{
$rows = $this->generateTable($data);
$header = $this->configurationService->get('export.labels', null);
@@ -189,9 +194,15 @@ class ReportCsv implements ReportCsvInterface
return [];
}
$explodeMinus = fn($ticket) => explode('-', $ticket)[0] ?? 'UNKNOWN';
- [$previous, $time_sum, $project_time, $table, $all_projects] = [$data[0]['id'], 0, 0, [], [$explodeMinus($data[0]['id'])]];
+ [$previous, $time_sum, $project_time, $table, $all_projects] = [
+ $data[0]['id'],
+ 0,
+ 0,
+ [],
+ [$explodeMinus($data[0]['id'])]
+ ];
foreach ($data as $line) {
- $project = $explodeMinus($line['id']);
+ $project = $explodeMinus($line['id']);
$previous_project = $explodeMinus($previous);
if ($project !== $previous_project) {
// When project changes, add a sum of time for that project.
@@ -220,7 +231,7 @@ class ReportCsv implements ReportCsvInterface
/**
* {@inheritdoc}
*/
- protected function parseReportData(string $filePath) : array
+ protected function parseReportData(string $filePath): array
{
$output = [];
// @TODO replace with config service.
@@ -242,5 +253,4 @@ class ReportCsv implements ReportCsvInterface
}
return $output;
}
-
}
diff --git a/app/src/Utils/CsvReport/ReportCsvInterface.php b/app/src/Utils/CsvReport/ReportCsvInterface.php
index 2557957..a758a05 100644
--- a/app/src/Utils/CsvReport/ReportCsvInterface.php
+++ b/app/src/Utils/CsvReport/ReportCsvInterface.php
@@ -12,17 +12,17 @@ interface ReportCsvInterface
/**
* Normal separator.
*/
- const SEPARATOR_SOFT = false;
+ public const SEPARATOR_SOFT = false;
/**
* Medium separator. Next line bold.
*/
- const SEPARATOR_MEDIUM = null;
+ public const SEPARATOR_MEDIUM = null;
/**
* Next line should be bold and centered.
*/
- const SEPARATOR_HARD = 0;
+ public const SEPARATOR_HARD = 0;
/**
* Returns array of hours per configured projects.
@@ -32,14 +32,14 @@ interface ReportCsvInterface
*
* Project key as key and number of hours as value.
*/
- public function getInvoiceData(string $filePath) : array;
+ public function getInvoiceData(string $filePath): array;
/**
* Returns array of rows created from array of InvoiceElements.
*
* If row is null, it is meant to be a table separator.
*/
- public function generateTable(array $data) : array;
+ public function generateTable(array $data): array;
/**
* Data for default drunomics pdf export.
@@ -47,5 +47,5 @@ interface ReportCsvInterface
*
* Parsed data from csv report.
*/
- public function arangeDataForDefaultPdfExport(array $data) : array;
+ public function arangeDataForDefaultPdfExport(array $data): array;
}
diff --git a/app/src/Utils/Mailer/MailerService.php b/app/src/Utils/Mailer/MailerService.php
index 72b3380..eee2f23 100644
--- a/app/src/Utils/Mailer/MailerService.php
+++ b/app/src/Utils/Mailer/MailerService.php
@@ -52,17 +52,17 @@ class MailerService implements MailerInterface
$this->pdf = $pdf;
}
- public function setRecipients(array $to) : void
+ public function setRecipients(array $to): void
{
$this->to = $to;
}
- public function setSubject(string $subject) : void
+ public function setSubject(string $subject): void
{
$this->subject = $subject;
}
- public function setAttachment(string $path) : void
+ public function setAttachment(string $path): void
{
// @TODO - add some error handling.
$this->attachment = $path;
@@ -115,7 +115,7 @@ class MailerService implements MailerInterface
return $this->password;
}
- public function sendMail(string $from, array $to, string $subject, string $text, array $attachment = []) : void
+ public function sendMail(string $from, array $to, string $subject, string $text, array $attachment = []): void
{
$email = new Email();
$email->from($from);
@@ -153,9 +153,14 @@ class MailerService implements MailerInterface
return new Mailer($transport);
}
- public function sendDefaultMail(string $output) : void
+ public function sendDefaultMail(string $output): void
{
- $tokens = $this->pdf->gatherTokensForTemplate($this->getEmailTemplatePath(), false, $this->getDefaultTokens(), 'email.tokens');
+ $tokens = $this->pdf->gatherTokensForTemplate(
+ $this->getEmailTemplatePath(),
+ false,
+ $this->getDefaultTokens(),
+ 'email.tokens'
+ );
$text = $this->pdf->replaceTokensInTemplate($this->getEmailTemplatePath(), $tokens);
$this->sendMail(
$this->getProperty('from'),
@@ -166,7 +171,7 @@ class MailerService implements MailerInterface
);
}
- public function getDefaultTokens() : array
+ public function getDefaultTokens(): array
{
$tokens = [];
$date = strtotime('-1 month');
@@ -175,7 +180,7 @@ class MailerService implements MailerInterface
return $tokens;
}
- protected function getEmailTemplatePath() : ?string
+ protected function getEmailTemplatePath(): ?string
{
if (! isset($this->templatePath)) {
$template_path = $this->config->get('email.template_path', false);
@@ -190,7 +195,7 @@ class MailerService implements MailerInterface
return $this->templatePath;
}
- public function setEmailTemplatePath(string $path) : void
+ public function setEmailTemplatePath(string $path): void
{
if (file_exists($path)) {
$this->templatePath = $path;
diff --git a/app/src/Utils/PdfExport/PdfExportInterface.php b/app/src/Utils/PdfExport/PdfExportInterface.php
index 04c2e86..2f1b505 100644
--- a/app/src/Utils/PdfExport/PdfExportInterface.php
+++ b/app/src/Utils/PdfExport/PdfExportInterface.php
@@ -13,9 +13,9 @@ interface PdfExportInterface
* Retrieves path to template file either from command option, configuration
* or from uer input.
*/
- public function getTemplatePath() : ?string;
+ public function getTemplatePath(): ?string;
- public function setTemplatePath(string $path) : void;
+ public function setTemplatePath(string $path): void;
/**
* Creates html table from parsed csv data.
@@ -23,12 +23,12 @@ interface PdfExportInterface
*
* First line is header. The rest of them is table body.
*/
- public function parsedDataToHtmlTable(array $data) : ?string;
+ public function parsedDataToHtmlTable(array $data): ?string;
/**
* Reads the template file and replaces token values.
*/
- public function replaceTokensInTemplate(string $template_path, array $tokens) : ?string;
+ public function replaceTokensInTemplate(string $template_path, array $tokens): ?string;
/**
* Creates and export file.
@@ -38,7 +38,7 @@ interface PdfExportInterface
*
* True if export was successfull.
*/
- public function pdfExport(string $html) : bool;
+ public function pdfExport(string $html): bool;
/**
* Goes through the whole process of creating a pdf for the invoice.
@@ -48,7 +48,7 @@ interface PdfExportInterface
*
* Path of the pdf file.
*/
- public function fromDefaultDataToPdf(array $nice_data, array $tokens = []) : string;
+ public function fromDefaultDataToPdf(array $nice_data, array $tokens = []): string;
/**
* Sets output file override via command paramater.
@@ -56,7 +56,7 @@ interface PdfExportInterface
*
* Path of the output pdf file ('/tmp/test.pdf').
*/
- public function setOutput(string $output) : void;
+ public function setOutput(string $output): void;
// @TODO support multiple templates by adding template id in config.
// @TODO implement twig.
@@ -75,5 +75,10 @@ interface PdfExportInterface
*
* Token keys and values array.
*/
- public function gatherTokensForTemplate(string $template_path, bool $skip_missing, array $runtime_tokens = [], string $config = 'export.token') : array;
+ public function gatherTokensForTemplate(
+ string $template_path,
+ bool $skip_missing,
+ array $runtime_tokens = [],
+ string $config = 'export.token'
+ ): array;
}
diff --git a/app/src/Utils/PdfExport/PdfExportService.php b/app/src/Utils/PdfExport/PdfExportService.php
index 0972825..32c50a0 100644
--- a/app/src/Utils/PdfExport/PdfExportService.php
+++ b/app/src/Utils/PdfExport/PdfExportService.php
@@ -35,7 +35,7 @@ class PdfExportService implements PdfExportInterface
$this->mpdf = $mpdf;
}
- public function getTemplatePath() : ?string
+ public function getTemplatePath(): ?string
{
if (! isset($this->templatePath)) {
$template_path = $this->config->get('export.template_path', false);
@@ -50,7 +50,7 @@ class PdfExportService implements PdfExportInterface
return $this->templatePath;
}
- public function setTemplatePath(string $path) : void
+ public function setTemplatePath(string $path): void
{
if (file_exists($path)) {
$this->templatePath = $path;
@@ -64,7 +64,7 @@ class PdfExportService implements PdfExportInterface
// @TODO would it make sense to allow more per user extending?
// @TODO - too much assumptions on data structure. Create a class with
// precise data structure and use that to pass the data around.
- public function parsedDataToHtmlTable(array $data) : ?string
+ public function parsedDataToHtmlTable(array $data): ?string
{
$table = '