Skip to content

Commit

Permalink
fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienPillevesse committed Aug 17, 2023
1 parent adf3ba8 commit e1c7df2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/FacturX.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getPdfContent(): string
$document->loadXML($this->xmlContent);

$pdfStreamReader = StreamReader::createByString($this->pdfContent);
$xmlStreamReader= StreamReader::createByString($this->xmlContent);
$xmlStreamReader = StreamReader::createByString($this->xmlContent);

$pdfWriter = new FdpiFacturx();
$pageCount = $pdfWriter->setSourceFile($pdfStreamReader);
Expand Down Expand Up @@ -130,7 +130,7 @@ public function getPdfContent(): string
$pdfWriter->SetPDFVersion('1.7', true);
$pdfWriter = $this->updatePdfMetadata($pdfWriter, $document);

return $pdfWriter->Output( 'S', 'invoice-facturx-' . date('Ymdhis') . '.pdf');
return $pdfWriter->Output('S', 'invoice-facturx-' . date('Ymdhis') . '.pdf');
}

public function addFacturxLogo(): void
Expand Down Expand Up @@ -390,7 +390,7 @@ private function extractInvoiceInformations(\DOMDocument $document): array
{
$xpath = new \DOMXpath($document);

/** @var \DOMNodeList<\DOMDocument> $dateElements */
/** @var \DOMNodeList<\DOMElement> $dateElements */
$dateElements = $xpath->query('//rsm:ExchangedDocument/ram:IssueDateTime/udt:DateTimeString');
$dateItem = $dateElements->item(0);

Expand All @@ -404,8 +404,14 @@ private function extractInvoiceInformations(\DOMDocument $document): array
throw new \Exception('DateTimeString element is missing in XML.');
}

$dateObject = (\DateTime::createFromFormat('Ymd', $date))->format('Y-m-d');
$strToTimeDate = strtotime($dateObject);
$dateObject = \DateTime::createFromFormat('Ymd', $date);

if (!$dateObject) {
throw new \Exception('DateTimeString element is malformed.');
}

$formattedDateObject = $dateObject->format('Y-m-d');
$strToTimeDate = strtotime($formattedDateObject);

if (!$strToTimeDate) {
throw new \Exception('DateTimeString element is malformed in XML.');
Expand Down

0 comments on commit e1c7df2

Please sign in to comment.