AvocadoBurger   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 32
loc 32
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getPrice() 4 4 1
A getDescription() 4 4 1

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
declare(strict_types=1);
3
4
namespace codenixsv\Patterns\Structural\Decorator;
5
6
/**
7
 * Class AvocadoBurger
8
 * @package codenixsv\Patterns\Structural\Decorator
9
 */
10 View Code Duplication
class AvocadoBurger implements BurgerInterface
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 BurgerInterface
14
     */
15
    private $burger;
16
17
    /**
18
     * CheeseBurger constructor.
19
     * @param BurgerInterface $burger
20
     */
21 2
    public function __construct(BurgerInterface $burger)
22
    {
23 2
        $this->burger = $burger;
24 2
    }
25
26
    /**
27
     * @return int
28
     */
29 2
    public function getPrice(): int
30
    {
31 2
        return $this->burger->getPrice() + 3;
32
    }
33
34
    /**
35
     * @return string
36
     */
37 2
    public function getDescription(): string
38
    {
39 2
        return $this->burger->getDescription() . ' with avocado';
40
    }
41
}
42