Pdf::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 6
rs 10
1
<?php
2
namespace Eduardokum\CorreiosPhp\Render;
3
4
use Eduardokum\CorreiosPhp\Config\Testing;
5
use Eduardokum\CorreiosPhp\Contracts\Config\Config as ConfigContract;
6
7
abstract class Pdf
8
{
9
    /**
10
     * @var \TCPDF
11
     */
12
    protected $tcpdf;
13
14
    /**
15
     * @var ConfigContract
16
     */
17
    protected $config;
18
19
    /**
20
     * @var int
21
     */
22
    protected $padding = 1;
23
24
    /**
25
     * @var mixed|string
26
     */
27
    protected $fontRegular;
28
29
    /**
30
     * @var mixed|string
31
     */
32
    protected $fontBold;
33
34
    public function __construct(ConfigContract $config = null)
35
    {
36
        $this->config = $config ?: new Testing();
37
        $this->fontRegular = \TCPDF_FONTS::addTTFfont(CORREIOS_PHP_BASE . '/resources/assets/fonts/Arial.ttf', 'TrueTypeUnicode', '', 96);
38
        $this->fontBold = \TCPDF_FONTS::addTTFfont(CORREIOS_PHP_BASE . '/resources/assets/fonts/ArialBold.ttf', 'TrueTypeUnicode', '', 96);
39
    }
40
41
    /**
42
     * @return ConfigContract
43
     */
44
    public function getConfig()
45
    {
46
        return $this->config;
47
    }
48
49
    /**
50
     * @param        $h
51
     * @param        $txt
52
     * @param string $link
53
     * @param bool   $fill
54
     * @param string $align
55
     * @param bool   $ln
56
     * @param int    $stretch
57
     * @param bool   $firstline
58
     * @param bool   $firstblock
59
     * @param int    $maxh
60
     * @param int    $wadj
61
     * @param string $margin
62
     */
63
    protected function writeBold($h, $txt, $link = '', $fill = false, $align = '', $ln = false, $stretch = 0, $firstline = false, $firstblock = false, $maxh = 0, $wadj = 0, $margin = '')
64
    {
65
        $this->tcpdf->SetFont($this->fontBold, 'B');
66
        $this->tcpdf->Write($h, $txt, $link, $fill, $align, $ln, $stretch, $firstline, $firstblock, $maxh, $wadj, $margin);
67
        $this->tcpdf->SetFont($this->fontRegular, null);
68
    }
69
}