These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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
|
|||
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 |
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.