Completed
Push — master ( 32e5f0...27d566 )
by Hannes
47:58
created

FileSource::getContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace iio\libmergepdf;
4
5
use setasign\Fpdi\PdfParser\StreamReader;
6
7
/**
8
 * Pdf source from file
9
 */
10 View Code Duplication
class FileSource implements SourceInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /**
13
     * @var string
14
     */
15
    private $filename;
16
17
    /**
18
     * @var Pages
19
     */
20
    private $pages;
21
22
    /**
23
     * @param string $filename
24
     * @param Pages  $pages
25
     */
26
    public function __construct($filename, Pages $pages = null)
27
    {
28
        $this->filename = $filename;
29
        $this->pages = $pages ?: new Pages;
30
    }
31
32
    public function getName()
33
    {
34
        return $this->filename;
35
    }
36
37
    public function getContents()
38
    {
39
        return file_get_contents($this->filename);
40
    }
41
42
    public function getStreamReader()
43
    {
44
        return StreamReader::createByFile($this->filename);
45
    }
46
47
    public function getPages()
48
    {
49
        return $this->pages;
50
    }
51
}
52