Test Failed
Push — main ( 961615...d5171d )
by Andreas
12:44 queued 13s
created

Pages::importFromDump()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 25
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 25
ccs 14
cts 14
cp 1
rs 9.7333
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * PDFtk wrapper
4
 *
5
 * @copyright 2014-2024 Institute of Legal Medicine, Medical University of Innsbruck
6
 * @author Andreas Erhard <[email protected]>
7
 * @license LGPL-3.0-only
8
 * @link http://www.gerichtsmedizin.at/
9
 *
10
 * @package pdftk
11
 */
12
13
namespace Gmi\Toolkit\Pdftk;
14
15
/**
16
 * Read PDF page information.
17
 */
18
class Pages
19
{
20
    /**
21
     * Pages.
22
     *
23
     * @var Page[]
24
     */
25
    private $pages = [];
26
27
    /**
28
     * @var WrapperInterface
29
     */
30
    private $wrapper;
31
32
    /**
33
     * Constructor.
34
     */
35
    public function __construct(WrapperInterface $wrapper = null)
36
    {
37 10
        $this->wrapper = $wrapper ?: new PdftkWrapper();
38
    }
39 10
40 10
    /**
41
     * Add page to the pages array.
42
     */
43
    public function add(Page $page): self
44
    {
45
        $this->pages[] = $page;
46
47 5
        return $this;
48
    }
49 5
50
    /**
51
     * Returns all pages.
52
     *
53
     * @return Page[]
54
     */
55
    public function all(): array
56
    {
57 2
        return $this->pages;
58
    }
59 2
60
    /**
61 2
     * Remove all pages.
62
     */
63
    public function clear(): self
64
    {
65
        $this->pages = [];
66
67
        return $this;
68
    }
69
70
    /**
71 4
     * Imports pages from a PDF file.
72
     *
73 4
     * @throws PdfException
74 3
     */
75
    public function import(string $infile): self
76 3
    {
77
        $this->wrapper->importPages($this, $infile);
78
79
        return $this;
80
    }
81
}
82