Passed
Push — master ( 3db12d...858816 )
by Sébastien
03:31
created

EntryBook   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 46.15 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
dl 18
loc 39
ccs 5
cts 15
cp 0.3333
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getCoverThumbnail() 9 9 3
A getCover() 9 9 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * COPS (Calibre OPDS PHP Server) class file
4
 *
5
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6
 * @author     Sébastien Lucas <[email protected]>
7
 */
8
9
class EntryBook extends Entry
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
10
{
11
    public $book;
12
13
    /**
14
     * EntryBook constructor.
15
     * @param string $ptitle
16
     * @param integer $pid
17
     * @param string $pcontent
18
     * @param string $pcontentType
19
     * @param array $plinkArray
20
     * @param Book $pbook
21
     */
22 41
    public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) {
23 41
        parent::__construct ($ptitle, $pid, $pcontent, $pcontentType, $plinkArray);
24 41
        $this->book = $pbook;
25 41
        $this->localUpdated = $pbook->timestamp;
26 41
    }
27
28 View Code Duplication
    public function getCoverThumbnail () {
0 ignored issues
show
Duplication introduced by
This method 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...
29
        foreach ($this->linkArray as $link) {
30
            /* @var $link LinkNavigation */
31
32
            if ($link->rel == Link::OPDS_THUMBNAIL_TYPE)
33
                return $link->hrefXhtml ();
34
        }
35
        return null;
36
    }
37
38 View Code Duplication
    public function getCover () {
0 ignored issues
show
Duplication introduced by
This method 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...
39
        foreach ($this->linkArray as $link) {
40
            /* @var $link LinkNavigation */
41
42
            if ($link->rel == Link::OPDS_IMAGE_TYPE)
43
                return $link->hrefXhtml ();
44
        }
45
        return null;
46
    }
47
}
48