PdfTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getParser() 0 7 2
A createPdf() 0 4 1
1
<?php
2
/**
3
 * Webino (http://webino.sk/)
4
 *
5
 * @link        https://github.com/webino/WebinoDev/ for the canonical source repository
6
 * @copyright   Copyright (c) 2014-2017 Webino, s. r. o. (http://webino.sk/)
7
 * @license     BSD-3-Clause
8
 */
9
10
namespace WebinoDev\Test;
11
12
use Smalot\PdfParser\Parser;
13
14
/**
15
 * Test PDF trait
16
 *
17
 * Use this trait when you want PDF testing.
18
 */
19
trait PdfTrait
20
{
21
    /**
22
     * @var Parser
23
     */
24
    private $parser;
25
26
    /**
27
     *
28
     * @return Parser
29
     */
30
    private function getParser()
31
    {
32
        if (null === $this->parser) {
33
            $this->parser = new Parser;
34
        }
35
        return $this->parser;
36
    }
37
38
    /**
39
     * Create DOM document from XHTML source
40
     *
41
     * @param string $source
42
     * @return \Smalot\PdfParser\Document
43
     */
44
    protected function createPdf($source)
45
    {
46
        return $this->getParser()->parseContent($source);
47
    }
48
}
49