Skip to content

Commit 7f055a1

Browse files
committed
improved code style and used more typehints
Signed-off-by: Christoph Massmann <[email protected]>
1 parent fc9c23f commit 7f055a1

File tree

3 files changed

+30
-80
lines changed

3 files changed

+30
-80
lines changed

src/Model/Document.php

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
3-
* Pdf document class
4-
*
55
* @section LICENSE
66
* This file is created by vianetz <[email protected]>.
77
* The code is distributed under the GPL license.
@@ -21,72 +21,43 @@
2121

2222
class Document implements DocumentInterface
2323
{
24-
/** @var string */
25-
private $htmlContents;
26-
27-
/** @var string */
28-
private $pdfBackgroundFile = '';
24+
private string $htmlContents;
25+
private string $pdfBackgroundFile = '';
26+
private string $pdfBackgroundFileForFirstPage = '';
2927

30-
/** @var string */
31-
private $pdfBackgroundFileForFirstPage = '';
32-
33-
/**
34-
* @param string $htmlContents
35-
*
36-
* @return \Vianetz\Pdf\Model\Document
37-
*/
38-
public function setHtmlContents($htmlContents)
28+
public function setHtmlContents(string $htmlContents): self
3929
{
4030
$this->htmlContents = $htmlContents;
31+
4132
return $this;
4233
}
4334

44-
/**
45-
* @return string
46-
*/
47-
public function getHtmlContents()
35+
public function getHtmlContents(): string
4836
{
4937
return $this->htmlContents;
5038
}
5139

52-
/**
53-
* @return string
54-
*/
55-
public function getPdfBackgroundFile()
40+
public function getPdfBackgroundFile(): string
5641
{
5742
return $this->pdfBackgroundFile;
5843
}
5944

60-
/**
61-
* @param string $pdfFile
62-
* @return void
63-
*/
64-
public function setPdfBackgroundFile($pdfFile)
45+
public function setPdfBackgroundFile(string $pdfBackgroundFile): void
6546
{
66-
$this->pdfBackgroundFile = $pdfFile;
47+
$this->pdfBackgroundFile = $pdfBackgroundFile;
6748
}
6849

69-
/**
70-
* @return string
71-
*/
72-
public function getPdfBackgroundFileForFirstPage()
50+
public function getPdfBackgroundFileForFirstPage(): string
7351
{
7452
return $this->pdfBackgroundFileForFirstPage;
7553
}
7654

77-
/**
78-
* @param string $pdfFile
79-
* @return void
80-
*/
81-
public function setPdfBackgroundFileForFirstPage($pdfFile)
55+
public function setPdfBackgroundFileForFirstPage(string $pdfBackgroundFileForFirstPage): void
8256
{
83-
$this->pdfBackgroundFileForFirstPage = $pdfFile;
57+
$this->pdfBackgroundFileForFirstPage = $pdfBackgroundFileForFirstPage;
8458
}
8559

86-
/**
87-
* @return string
88-
*/
89-
public function getDocumentType()
60+
public function getDocumentType(): string
9061
{
9162
return '';
9263
}

src/Model/DocumentInterface.php

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
35
* @section LICENSE
46
* This file is created by vianetz <[email protected]>.
@@ -17,42 +19,18 @@
1719

1820
namespace Vianetz\Pdf\Model;
1921

20-
/**
21-
* @todo rename to HtmlDocumentInterface
22-
*/
22+
/** @todo rename to HtmlDocumentInterface */
2323
interface DocumentInterface
2424
{
25-
/**
26-
* Return HTML file contents for conversion to PDF.
27-
*
28-
* @return string
29-
*/
30-
public function getHtmlContents();
31-
32-
/**
33-
* @return string
34-
*/
35-
public function getPdfBackgroundFile();
36-
37-
/**
38-
* @param string $pdfFile
39-
* @return void
40-
*/
41-
public function setPdfBackgroundFile($pdfFile);
42-
43-
/**
44-
* @return string
45-
*/
46-
public function getPdfBackgroundFileForFirstPage();
47-
48-
/**
49-
* @param string $pdfFile
50-
* @return void
51-
*/
52-
public function setPdfBackgroundFileForFirstPage($pdfFile);
53-
54-
/**
55-
* @return string
56-
*/
57-
public function getDocumentType();
25+
public function getHtmlContents(): string;
26+
27+
public function getPdfBackgroundFile(): string;
28+
29+
public function setPdfBackgroundFile(string $pdfFile): void;
30+
31+
public function getPdfBackgroundFileForFirstPage(): string;
32+
33+
public function setPdfBackgroundFileForFirstPage(string $pdfFile): void;
34+
35+
public function getDocumentType(): string;
5836
}

src/Model/Generator/Dompdf.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ private function getDompdfOptions(): array
8484
'isPhpEnabled' => true,
8585
'isRemoteEnabled' => true,
8686
'chroot' => $this->config->getChrootDir(),
87+
'fontCache' => $this->config->getTempDir(),
8788
];
8889
}
8990

0 commit comments

Comments
 (0)