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 raw string |
||
9 | */ |
||
10 | View Code Duplication | class RawSource implements SourceInterface |
|
0 ignored issues
–
show
|
|||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | private $contents; |
||
16 | |||
17 | /** |
||
18 | * @var Pages |
||
19 | */ |
||
20 | private $pages; |
||
21 | |||
22 | /** |
||
23 | * @param string $contents |
||
24 | * @param Pages $pages |
||
25 | */ |
||
26 | public function __construct($contents, Pages $pages = null) |
||
27 | { |
||
28 | $this->contents = $contents; |
||
29 | $this->pages = $pages ?: new Pages; |
||
30 | } |
||
31 | |||
32 | public function getName() |
||
33 | { |
||
34 | return "raw-content"; |
||
35 | } |
||
36 | |||
37 | public function getContents() |
||
38 | { |
||
39 | return $this->contents; |
||
40 | } |
||
41 | |||
42 | public function getStreamReader() |
||
43 | { |
||
44 | return StreamReader::createByString($this->contents); |
||
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.