Completed
Branch BUG/11155/fix-payment-capabili... (cfe1f5)
by
unknown
40:48 queued 27:10
created

Context   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 63
loc 63
rs 10
c 1
b 0
f 0
wmc 5
lcom 0
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A slug() 4 4 1
A setSlug() 4 4 1
A description() 4 4 1
A setDescription() 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
3
namespace EventEspresso\core\domain\entities\contexts;
4
5
defined('EVENT_ESPRESSO_VERSION') || exit;
6
7
8
9
/**
10
 * Class Context
11
 * Simple DTO for conveying the background details about why some other logic is being performed,
12
 * that can assist with the decision making process or simply enhance logging.
13
 *
14
 * @package EventEspresso\core\domain\entities
15
 * @author  Brent Christensen
16
 * @since   4.9.46.rc.076
17
 */
18 View Code Duplication
class Context implements ContextInterface
19
{
20
21
    /**
22
     * @var string $slug
23
     */
24
    private $slug;
25
26
    /**
27
     * @var string $description
28
     */
29
    private $description;
30
31
32
    /**
33
     * Context constructor.
34
     *
35
     * @param string $slug
36
     * @param string $description
37
     */
38
    public function __construct($slug, $description)
39
    {
40
        $this->setSlug($slug);
41
        $this->setDescription($description);
42
    }
43
44
45
    /**
46
     * @return string
47
     */
48
    public function slug()
49
    {
50
        return $this->slug;
51
    }
52
53
54
    /**
55
     * @param string $slug
56
     */
57
    private function setSlug($slug)
58
    {
59
        $this->slug = sanitize_key($slug);
60
    }
61
62
63
    /**
64
     * @return string
65
     */
66
    public function description()
67
    {
68
        return $this->description;
69
    }
70
71
72
    /**
73
     * @param string $description
74
     */
75
    private function setDescription($description)
76
    {
77
        $this->description = sanitize_text_field($description);
78
    }
79
80
}
81
// Location: Context.php
82